Microsoft
Software
Hardware
Network
Question : MYSQL SELECT based on criteria from a second table
Here's the mess I got myself into:
I set up products table like this
id | category | etc
1 4
2 2
.
.
.
categories table like this
id | category | sub_category | description | etc
1 hinges clip-on
2 hinges compact
3 plates clip-on
.
.
.
This has worked for most situations far because I usually have the sub_category id handy before doing a product query. I am only now realizing that I don't have the knowledge of how to write a query that will select something based on the "primary" category without doing two separate queries and a lot of php :(
For example: if I want products from category 'hinges' I need a way of having the query select 1 AND 2 from the products table.
I'm kind of new at this. I'm not very good with JOINs but I feel like that might be part of the solution?
Also I'm trying to do this the "dry" way...but someone let me know if I'm on the wrong path altogether!!
Thanks in advance!
Answer : MYSQL SELECT based on criteria from a second table
SELECT a.*, b.* FROM products as a, category as b WHERE b.category='hinges' AND a.id = b.id
Random Solutions
Change Mac disk to from case-sensitive, Journaled to Case-insensitive, Journaled.
Need a driver for sm bus controller on Dell d620
Mouse slow in Google Chrome after attempted XP sp3 update
FILTERING EXCEL DATA USING VALUES FROM 2ND WORKSHEET
Exchange 2003 (SBS) not sending or receiving.
Access VBA Word merge
Er diagram for university accommodation office
Update IPSEC VPN client pcf file via ASA 8.2(2) Autoupdate
How to clear a datagridview
VPN between SSG 20 and RVO42 does not come up. "ERROR: Peer did not send a proxy id"