Forum Moderators: phranque

Message Too Old, No Replies

SQL Select statement problem

         

kevinj

1:12 am on Nov 22, 2002 (gmt 0)

10+ Year Member



I have two tables called exhibitors and badges that both have a field called exhibitor_id. I want to select all exhibitor_id values from the exhibitor table that do not appear in the exhibitor_id values from the badges table. Here is the sql statement I have so far (obviously NOTIN is the problem):

SELECT
e.exhibitor_name from exhibitors e, badges b where e.exhibitor_id NOTIN b.exhibitor_id

Any help would be greatly appreciated.

jatar_k

1:18 am on Nov 22, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



select e.exhibitor_name from exhibitors e, badges b where e.exhibitor_id NOT IN (select b.exhibitor_id from badges b)

I think that's right what sql is it?

kevinj

1:36 am on Nov 22, 2002 (gmt 0)

10+ Year Member



Thanks Jatar! That worked perfectly.

txbakers

1:58 pm on Nov 22, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's funny though, because although that is indeed the correct SQL statement, it doesn't work in mySQL.

mySQL doesn't support subselects or unions at this time.

It was a real crisis until I learned how to write it in reverse:

SELECT distinct categ,budgets.code FROM budgets left join budtrans on budgets.code =budtrans.code and budgets.schcode = budtrans.schcode WHERE budgets.schCode = 'WHS' and budtrans.code is null

This returns the same data, but without the subselect.

jatar_k

10:08 pm on Nov 22, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That was why i was asking about what sql. I took a shot that it wasn't mysql and figured kevinj would tell me soon enough because it wouldn't work.

That is a sweet little select txbakers.