Xrum! - Forum

Full Version: SQL query
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i could google, but i thought i'd try xrum first. maybe someone can give me a quick query code for this.


what i need is:

let's say i have 2 tables.
First table contains first nme and last name
Scond table contains address and phone number

they are linked by ID number.

i want to do a search. right now i can only do this:

Code:
Select * from firsttable where first_name  like ("something") or last_name like ("something");

how can i search for that something in both tables with the same request? can i have multiple "selects" in the same request? is that even possible?


Thanks!
Use Joins.
Example:
You want to get all my info from both tables:


SELECT A.FirstName, A.LastName, B.Address, B.PhoneNumber FROM FirstTable A, SecondTable B WHERE A.IDNUMBER = B.IDNUMBER AND A.USERNAME = 'GRRemlin'
The syntax in MySQL may differ a bit, but the concept and logic are the same.
i hate joins Smile

alright. thanks! i'm gonna try that.

my main issue was to get the friggin search to work, becuase i want it to search from both tables.

Thanks!
You'll be surprised, but I hate joins too!
And you're welcome Smile
Reference URL's