MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 20th, 2013, 01:25 PM
Antonioj1015 Antonioj1015 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2009
Posts: 4 Antonioj1015 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 53 sec
Reputation Power: 0
Question I need help selecting records in table a that are not in table b

I need to select the records that are in table_a but not in table_b, the thing is that I also need to select the records in table_a that dont have birthdate and the records on table_b that doesnt have answers, something like this:

SELECT pacient.* FROM pacient
LEFT JOIN test
ON pacient.idpacient = test.idpacient
WHERE test.idpacient IS NULL
OR pacient.date_birth IS NULL
OR test.answer = 0

To clear it all out I need the records of the persons that dont have birthdate, or are not in table_b or that their answer is 0

HOW CAN I SELECT the records that are in table_a but not in table_b, or the records in table_a that dont have birthdate and the records on table_b that dont have answers??

Table pacient
id | name | datebirth
1 | Jose | 1989-10-15
2 | Mark | 1985-10-15
3 | Maria | 1984-10-15
4 | Liz | NULL
5 | Joe | 1990-01-25

Table test
id | id_pacient | answer
1 | 1 | 1
2 | 3 | 5
3 | 4 | 1
4 | 5 | 0

The query I want to make should display the following pacients:
2 Mark (Who doesnt appear in the test table)
4 Liz (Who doesnt have a birth date even though she has an answer in the test table);
5 Joe (Who has 0 in the answer column in the test table );

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > I need help selecting records in table a that are not in table b


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap