vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I want to achieve something of this effect, but this is obviously not allowed is SQL. select name from Names where yearOfBirth = 1983 AND school = (select schoolName from Schools where state = 'NY') This subquery will return multiple values. But I want the names of all people who were born in 1983 and when to any school in New York. But the name and schoolName are stored in different tables. So what is a work-around for this? Hope the above is not too ambiguous. |
| |||
| If the subquery will return multiple values, use IN rather than EQUALS, i.e. "school IN ( select schoolName..." Or use a join: select n.name from Names n, Schools s where n.yearOfBirth = 1983 and n.school = s.schoolName and s.state = 'NY' Does your database really not allow for a person potentially attending more than one school? |