PDA

View Full Version : Simple query help please


Antivirus
10-30-2008, 03:54 PM
I've been wondering if I could do the following with a query, as opposed to using php.

I have two profile fields, `field1` and `field15` which each have strings within (or may be empty).

What I want to do is pull the info from field1, and append it to that within field 15. This is quite simple to do via php & mysql, but is it at all possible to do with only a query?

Adrian Schneider
10-30-2008, 04:15 PM
if field1 = 'abc' and field2 = 'def'

select concat(field1, field2) as letters

Antivirus
10-30-2008, 11:36 PM
thanks siradrian - perhaps I should have been clearer though, what I meant was doing it with one UPDATE query, in other words updating the actual database field15, not just selecting it :)

Marco van Herwaarden
10-31-2008, 10:07 AM
That would be almost the same:

UPDATE table
SET field15 = CONCAT(field1, field2)
WHERE condition if needed