hi
i have two different table,i want to select the name and id(primary key) from the first table..based on the id..i want to select the rest of the data in the second table...

the below query is showing error,plz do tell me the bug.

$query="select id,name from table1 where id='$id' IN(select spid,age,address from table2 where age1= '$age')";
thanks

i was not sure,i taught joins will help me....
i have a table1 it contains id(primary key),name....
in the second table i want to select the data based on id and i am want to use condition for students based on their marks..

can you show the table structure and what columns do you want from both the tables and on what criteria ? If you want to use joins, you can do it this way. select table1.id, table1.name, table2.col_name1,table2.col_name2 where table1.id=table2.spid; This will list all the records from table1 and table2 based on the condition id(table1) = spid(table2).

table1 contains
id(primary key)
name
pss
std....

table2
id
rank....

on the form side i have dropdown,2 text boxes.the drop down should display the students name..when the admin clicks the name and gives the rank (ex 1 to 10)

it should display all the students name and who gave got rank from 1 to 10...

i am trying query for this...........

why does the admin selects the student's name from the dropdown list ? anyway, you can use this query. select * from table1 where id IN (select id from table2 where rank BETWEEN 'textbox1' AND 'textbox2' ) This query will select all the rows in table 1 whose rank is between 1 and 10 of table2.

thanks for the reply...
you have not given any criteria for the drop down content...
sorry...wen he select a name in the dropdown,grade in the text boxes it should display all the subjects in the

select * from table1 where id=$id IN (select id from table2 where rank BETWEEN 'textbox1' AND 'textbox2' )

i want to know whether the above query is correct...i want something like that

select * from table1 where id=$id IN (select id from table2 where rank BETWEEN 'textbox1' AND 'textbox2' )
i want to know whether the above query is correct...i want something like that

Why don't you test it yourself. :)

i tested the above query it is not working...but i am trying to achieve something like that

it works for me though. oh, btw, textbox1 and textbox2 holds the range of rank. And unless you show us what you have done so far, its difficult for us to know what exactly you want.

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.