sub select in mysql

Hi im trying to make a query using sub selects, but this feature is not supported in my mysql version. what im trying to do is to get all the records that appears in one table but not in the other table. im doing something like this:
FROM problema
problema.no_problema NOT IN (

SELECT calif.n_problema
FROM calif
WHERE calif.n_control = '03040925'

In my local machine it works, i have the latest version of mysql, but in the server its not working and im not able to update the version.
I hope you can tell me a different solution to do this query



  • Try this on your server to make sure you get the same results...
    SELECT problema.*
    FROM problema
    LEFT JOIN calif
    ON problema.no_problema = calif.n_problema
    AND calif.n_control = '03040925'
    WHERE calif.n_problema IS NULL

    Basically this tries to match problema.no_problema and calif.n_problema, if calif.n_control = '03040925'. Then returns the ones where calif.n_problema IS NULL (same as NOT IN). I changed the SELECT to only select from problema, so the results should be identical except, perhaps the order.

    If you get the same number of records but it looks different, add an ORDER BY clause to check that the data is indeed the same.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion