Page 1 of 1

Joining Columns in Mysql Query

Posted: Fri Jun 19, 2009 7:56 am
by leewad
Hi

Does anyone know how I can query 2 fields in a mysql database as one?

for example there is 8 fields in a rental database and 2 of them are fields price_short, price_long this is where customers can add whether they offer longterm or short term rentals, so some may just add price in longterm and some in just shortterm.

How can I query both these fields at once and display which ever one has a value in it?

I have tried something like this but it dont work

Code: Select all

SELECT * FROM  $table  (SELECT price_short,price_long) AS price WHERE price =300

Re: Joining Columns in Mysql Query

Posted: Fri Jun 19, 2009 8:58 am
by jaoudestudios
You will need to use CASE.

Here is an example...http://www.forum.jaoudestudios.com/view ... ?f=13&t=12