Here’s the table structure
table : user
id
name
email
category
table 2 : body
id
uid
height
haircolor
Here’s how i access the data from the database
SELECT * FROM user WHERE category='paid' and with more codes it works.
What i want to do is like this (i..e allow complex search)
Select * FROM user WHERE category='paid' body.height='5ft', body.haircolor='red' WHERE user.id=body.uid
I know the statement is wrong, but i want the database to be searchable such that i can select haircolor as red, height as 5ft and the script should only return user(s) whose height is 5ft and haircolor is red (exact match)
I hope you guys understand my question.
P.S : As you can see i have used 2 tables, 1 to store user info and 2 to store user body info. I can integrate them into 1 but i want to keep it as it is.
You can actually do something very similar to what you’re doing above – you just use multiple tables in your FROM construct. It’s a great way when you want to pull something out quickly.
Remember to specify the SELECT in this instance – everything from the user table. You could also do this with a JOIN, although I have a phobia of them so tend to use the previous method.
That should do the trick! As I said, I despise using JOINs, and the former should be absolutely fine.