here’s the situation, i have 3 tables that look like this.
table foo
type number
a 1
b 2
c 3
d 4
table bar
number shape
1 square
2 circle
3 triangle
4 rectangle
table foobar
shape colour
square red
circle green
triangle blue
rectangle yellow
triangle purple
they all also have unique ids that I have not listed.
I have type but I want to find colour. now I could do three SQL requests to get it but as the SQL is likely to be the bottleneck so I was wondering if I could combine the three SQL requests into one request.
Is it possible to do this and would it run faster than three separate SQL requests
1 would return red and 3 would return blue and purple.
You can use
JOINSto join the rows and use a where clause to specify the type you want. It would definitely be faster then doing this: