|
Posted by Geoff May on 05/23/05 19:05
Dave wrote:
> Thanks Geoff,
>
> Did you mean:
> SELECT table_1.ID, table_1.NAME if(table_1.ID = table_2.ID, table_2.FLAG, 0)
> AS MY_FLAG
> FROM table_1, table_2
> WHERE table_1.ID LIKE '1000%' and table_1.ID = table_2.ID
> ORDER BY table_1.ID;
>
> If so this works but won't return the row:
> 10003 10002 name 0
>
> As the query is restricted by matching ID cols in both tables.
Then you need to use the JOIN, something like this:
SELECT table_1.ID, table_1.NAME, if(table_1.ID = table_2.ID,
table_2.FLAG, 0)
FROM table_1
left left join table_2 on (table_1.ID = table_2.ID)
where table_1.ID LIKE '1000%'
ORDER BY table_1.ID;
MfG
Geoff.
--
Unofficial F1 Database: http://glibs.ssmmdd.co.uk/
Update: 22nd May, 2005
USENET Email address is a spam trap, send Emails to address in the DB
Navigation:
[Reply to this message]
|