|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Simple join returning odd results
I have a very simple database set up where I use one table to display all the current link categories available, and another to hold the respective links. 'catid' is the primary key for the 'link_cat' table and the foreign key to the 'links' table.
Everything works well, but on an administrative section of the site, I give the owner the ability to add/edit/delete the categories and links. I simply loop through both tables and list all the categories with an 'edit' and 'delete' button next to it and a seperate table for the 'links' table. This too works well, but I'd like to isolate the categories that exist, but don't have any links associated with them yet, and stray links lying around after the category they were once associated with no longer exist. LINK_CAT TABLE --------------- catid <-- pri key cat_name LINKS TABLE ----------- linkid <-- pri key catid <-- foreign key link_url alt When I use this query, it comes back correct. It returns the link(s) which have an existing catid in the 'link_cat' table PHP Code:
However if I try this one, it returns everything twice, PLUS it also returns the link that has a matching catid in the 'link_cat' table?? PHP Code:
The only difference in them is the '!' in front of the '=' on the second query. I'm not even sure if I'm going at this the right way. I appreciate all suggestions. (I uploaded a zip file of the tables if anyone wants to look) Thanks ![]() |
|
#2
|
||||
|
||||
|
Use and LEFT JOIN - and check for NULL in the link field key field.... I believe MadCow posted the answer for this about a week ago...
|
|
#3
|
|||
|
|||
|
I searched all of MadCowDzz's recent post and didn't see a thread similar to mine. Would you be kind enough to show me an example of what you posted?
Thanks |
|
#4
|
||||
|
||||
|
Refering to this post?
http://forums.devarticles.com/showt...28104#post28104 |
|
#5
|
|||
|
|||
|
Quote:
No, stumpy mistakenly thought you addressed my post about a week ago, I then looked for your recent posts but didn't see any similar to mine . Would you take a look at my original post and tell me what you think? Robin ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > General SQL Development > Simple join returning odd results |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|