If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Finding Broken Links for Integrity Control

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-26-05, 06:25
gtk gtk is offline
Registered User
 
Join Date: Oct 2004
Location: Paris, FRANCE
Posts: 132
Post Finding Empty JOIN records

I'm trying to find broken links between two tables.
Performing that I can view all the links
Code:
SELECT
	t2.name AS "object",
	t1.name AS "group"
FROM
	t2
	LEFT JOIN t1 ON (t1.t1_id = t2.t1_id)
I get get something like that
Code:
+---------+-----------+
| object  | group     |
+---------+-----------+
| apple   | food      |
| bus     | vehicule  |
| car     | vehicule  |
| chair   | furniture |
| cheese  | food      |
| coat    | cloth     |
| metro   | vehicule  |
| noze    |           |
| table   | furniture |
| water   |           |
| window  |           |
| wine    |           |
+---------+-----------+
But i'm trying to get only the broken ones (objects having no group)
Code:
SELECT
	t2.name AS "object",
	t1.name AS "group"
FROM
	t2
	LEFT JOIN t1 ON (t1.t1_id = t2.t1_id)
WHERE
	t1.name = NULL
I'd like to get
Code:
+---------+-----------+
| object  | group     |
+---------+-----------+
| noze    |           |
| water   |           |
| window  |           |
| wine    |           |
+---------+-----------+
But this one gives me an empty result

Last edited by gtk; 09-26-05 at 07:09.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On