0

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,

)

3
Contributors
8
Replies
9
Views
9 Years
Discussion Span
Last Post by vssp
0

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..

0

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.

0

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
)

0

just add another condition ! SELECT * from attend where (day1 between '$from' and '$to') and spid='$id' :)

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.