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,

)

Re: sql query 80 80

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

Re: sql query 80 80

Subquery returns more than 1 row

Re: sql query 80 80

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.

Re: sql query 80 80

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
)

Re: sql query 80 80

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

Re: sql query 80 80

thanks......

Re: sql query 80 80

you are welcome :)

Re: sql query 80 80

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.