In one table but NOT in the other ?
I have two tables: PLATFORMS and MAIN
I want to select the platform id numbers that exist in PLATFORMS
but that have not yet been used in MAIN
In PLATFORMS the platform id number field is platform_id
and in MAIN, if the platform has been used, its id is in platform_no
This gives me ALL the platform names and ids:
Thanks for advice.
I tried these combinations:
I get a list of four of the platforms, the same list each time regardless of
whether the platform is on MAIN or not :confused::confused:
Just to clarify ...
The complete list is held by platforms, the partial "used" list is on main.
I am trying to get the ones that are on platforms but not on main.
Which is what that should do. I can't write an identical query, but I can do one off of a table I have. I use a set of keywords that are applied in many to many to servers, so if I want to find unused keywords than I write as:
Granted this isn't on a MySQL machine, but that shouldn't be an issue with the is null check.
If that's not working, you'll have to wait for pedant to come around and fix it up :P
FouLu's query should have worked.
Try it in a MySQL query tool instead of PHP.
But another way to write it is:
If it doesn't, then you have a problem in your data.
Thanks for your help.
OK - I SEE I HAVE FORGOTTEN TO INCLUDE THE PAGE_NO.
SO I NEED TO ALSO EXCLUDE ROWS THAT HAVE PAGE_NO = $Db_page_no in the MAIN table.
So I have added it below ...
This is the code I am using in my script:
And this is the data in the MAIN table:
The result I get when trying to use page_id 3 is:
As you see, I now get zero results:
Can you see what I have done wrong ?
My listing shows that Page 3 is allocated in platforms:
no. 1 - Meaty Monster Bikes
no. 3 - Hovercraft Kits
no. 4 - Robot Kits
So my expected result from the above query is:
no. 2 - Big Boat Kits.
( because page 3 is not allocated to platform 2 in MAIN )
But what I need to do is make the query ALSO output the
rows that are not in MAIN but are in PLATFORMS
So my final result SHOULD BE:
no. 2 - Big Boat Kits.
no. 5 - Sail Boat Kits.
no. 6 - Jet Boat Plans
no. 7 - Build Boat Kits
no. 8 - Hovercraft DIY
I hope you see what I am trying to do and how I can do it :)
|All times are GMT +1. The time now is 12:49 PM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.