Hi, I have two tables setup as shown below:
Table name,"config"
+------+------+
| config_name | config_value |
+------+------+
| default_style | 1 |
| *other names | *other values |
+------+------+
Table name,"styles"
+------+------+
| style_id | style_name |
+------+------+
| 1 | Purple Hue |
| *other names | *other values |
+------+------+
Now, for my question:
I need to select everything (*) from the config table
and the 'style_name' from the styles table where style_id of the styles table is equal to the value of default_style of the config table.
I got as far as this query
"SELECT config.*, styles.style_name FROM `config`, `styles` WHERE config.default_style = styles.style_id LIMIT 1"
But obviously that will not work.
I know I can do this with two queries, but I am optimizing and I would like to reduce this down to 1 query, is this even possible to do with one query?
Thanks.left outer join|||Is this the same as a left join? I have heard of left join, but never of a left outer join.
Just an alias or what?|||yeah, it's the same
some databases allow the OUTER keyword to be optional
|
No comments:
Post a Comment