Click to See Complete Forum and Search --> : prefix to selected rows
toenailsin
06-04-2008, 07:11 AM
is it possible to add a prefix to selected rows?
i have a query that has multiple joins to the same table, thus returning the same column names. problem is i want to output all the info from these and a prefix would help define the difference between the results
yamaharuss
06-04-2008, 07:36 AM
Just name each one differently using the AS operator
Select table1.title AS tbl1Title, etc..
toenailsin
06-04-2008, 07:37 AM
yea, problem is that theres like 25 columns in the table, which is joined to 3 times. i don't feel like renaming 75 columns manually
yamaharuss
06-04-2008, 07:41 AM
Maybe I don't understand what you're asking for. Why would you need to use different prefixes for the same columns? If you were doing MAX or SUM selects I could see that.
You should post your query.
toenailsin
06-04-2008, 07:53 AM
SELECT
*
FROM
searches AS search
LEFT JOIN data AS d1 ON ( search.data_id1 = d1.id )
LEFT JOIN data AS d2 ON ( search.data_id2 = d2.id )
LEFT JOIN data AS d3 ON ( search.data_id3 = d3.id )
WHERE
search.id = 1
LIMIT 1
chazzy
06-04-2008, 08:18 AM
yamaharuss's solution is the correct one.
toenailsin
06-04-2008, 08:29 AM
i really don't want to do that 86 times (yea i counted them)
i'll find a different way to do what i want
mattyblah
06-06-2008, 12:50 AM
In the time you've taken to post you could have renamed the columns. There is no other way to do this. In the time you'll take trying to find another way, you could have renamed them multiple times. And a last not, select * is always bad.