sql query

Thread Solved

Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

sql query

 
0
  #1
Dec 18th, 2007
i have three table

1st viewleave
2nd applyleave
3rd personal

based on the leaveid in viewleavetable i wnt to fetch the spid in the second table,based on the spid i want to select spid email address........please tell how to do tat..
CREATE TABLE `viewleave` (
`leaveid` varchar(25) NOT NULL,
`message` varchar(500) NOT NULL
)

CREATE TABLE `applyleave` (
`leaveid` int(11) NOT NULL auto_increment,
`spid` varchar(25) NOT NULL
PRIMARY KEY (`leaveid`)
)

CREATE TABLE `personal` (
`spid` varchar(25) NOT NULL,
`email` varchar(60) NOT NULL,

)
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: sql query

 
0
  #2
Dec 18th, 2007
select email from personal where spid=(select spid from applyleave where leaveid=(select leaveid from viewleave where leaveid="specify your leaveid here"))

Hi.. Try this and let me know if this works..
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

Re: sql query

 
0
  #3
Dec 19th, 2007
Subquery returns more than 1 row
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: sql query

 
0
  #4
Dec 19th, 2007
That means there are many records with the same spid. You can change the above query to,
select email from personal where spid IN (select spid from applyleave where leaveid IN (select leaveid from viewleave where leaveid="specify your leaveid here"))

Cheers.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

sql query

 
0
  #5
Dec 19th, 2007
thanks it is working.........

i have a form where the candidate id,from-date and to-date will be given by the user..based on tat i want to exact data from the table

SELECT * from attend where day1 between '$from' and '$to';

i am able to extract date based on the condition given by the user,i want to exact on a particular id's date...how to do tat

this is my table...........

CREATE TABLE `attend` (
`spid` varchar(50) NOT NULL,
`day1` date NOT NULL,
`time1` varchar(50) NOT NULL
)
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: sql query

 
0
  #6
Dec 19th, 2007
just add another condition !
SELECT * from attend where (day1 between '$from' and '$to') and spid='$id'
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

Re: sql query

 
0
  #7
Dec 19th, 2007
thanks......
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,761
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: sql query

 
0
  #8
Dec 19th, 2007
you are welcome
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Re: sql query

 
0
  #9
Jan 7th, 2008
Hi friends

Please chk this query this also help for you
SELECT *
FROM applyleave a1, viewleave v1, personal p1
WHERE a1.leaveid = v1.leaveid
AND a1.spid = p1.spid
LIMIT 0 , 30
Thanks
VSSP
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1071 | Replies: 8
Thread Tools Search this Thread



Tag cloud for MySQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC