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,

)

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

Subquery returns more than 1 row

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.

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
)

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

thanks......

you are welcome :)

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.