mysql, to get rows in tblA that aren't in tblB for an item in tblB -


i'm trying query batchuuid batchtbl aren't in jobbatchstatustbl..

i've tried couple of different queries trying use like:

select *  batchtbl ba  left join jobbatchstatustbl j  on ba.batchuuid=j.batchuuid join jobtbl j2  on j.jobuuid=j2.jobuuid j.batchuuid null , j.jobuuid = 'ecd0fab8-8bf1-83cc-b1d7-495034a55618'; 

but i'm screwing up...

any thoughts?

thanks

mysql> select batchname,batchuuid batchtbl; +-----------+--------------------------------------+ | batchname | batchuuid                            | +-----------+--------------------------------------+ | aa        | d288ff51-d045-d218-52fd-93e3523db85e | | aa1       | a288ff51-d045-d218-52fd-93e3523db85e | | aa3       | d188ff51-d045-d218-52fd-93e3523db85e | | aaa3      | da88ff51-d045-d218-52fd-93e3523db85e | | baa3      | db88ff51-d045-d218-52fd-93e3523db85e | | z1        | 7eedfea4-c498-ed6e-f0dd-1397fe7dbd67 | | d1        | 34781dba-d99c-82e3-f499-b55ded863f81 | | nb        | 1dd56d9c-daed-7f9f-c13b-246d2ec96513 | | ds        | cca9a771-b5ef-5926-4c26-21151215a800 | | a1        | 1bb51584-e68a-21d1-a2df-e07707591b43 | +-----------+--------------------------------------+ 10 rows in set (0.00 sec)  mysql> select jobname,jobuuid jobtbl; +---------+--------------------------------------+ | jobname | jobuuid                              | +---------+--------------------------------------+ | aa      | 8afa9cf4-bf63-a4cd-3cd9-cbc6d17f84be | | aa1     | ecd0fab8-8bf1-83cc-b1d7-495034a55618 | +---------+--------------------------------------+ 2 rows in set (0.00 sec)  mysql> select jobuuid,batchuuid jobbatchstatustbl; +--------------------------------------+--------------------------------------+ | jobuuid                              | batchuuid                            | +--------------------------------------+--------------------------------------+ | ecd0fab8-8bf1-83cc-b1d7-495034a55618 | d288ff51-d045-d218-52fd-93e3523db85e | +--------------------------------------+--------------------------------------+ 1 row in set (0.00 sec) 

thanks

your query puts inner join on jobbatchstatustbl jobtbl, rows in 1 not other never returned @ all. need 2 of tables this:

select *    batchtbl   jobuuid     not      in (select jobuuid            jobbatchstatustbl)  

i should note it's impossible use jobuuid in clause you're attempting in initial query, because returning batches there no corresponding job, according post - makes me wonder if post misworded, since had specific job uuid in query?

on note, should never name tables, columns or else in way describes schema type.


Comments