Forum Moderators: coopster

Message Too Old, No Replies

sql append string

can i append using UPDATE

         

davejs

9:26 am on Sep 15, 2004 (gmt 0)

10+ Year Member



Hi

Hope someone can help me here...

I want to add a extra lump of text to a TEXT field within my sql database without first having to fetch the data.

with UPDATE you can update VALUES within a field by using:
UPDATE database SET columname=columnname+1

BUT this will only work with NON TEXT fields, is it possible to add an extra string to a TEXT filed somehow?

Ive tried but can't find if this is possible or not.

Cheers

Netizen

11:22 am on Sep 15, 2004 (gmt 0)

10+ Year Member



Try

UPDATE tablename SET columnname=concat(columnname,' my extra text');

which should do the trick.

davejs

1:04 pm on Sep 15, 2004 (gmt 0)

10+ Year Member



Many thanks thats great...

I have another sql question...( yes im new to sql!)

I want to order a set of results with a certain field acting as the sorting field..

I undertand ORDER BY is what i need... but i want the top results to be the ones with the MOST SAME DATA.

So if i have a field with 100 rows total
and 90 of the rows are = 1
and 5 are =99
and 4 are =6
and 1 is = 10

then the fetch would get 1,99,6,10.

so this shows that 1 has the most same entries,then 99 etc.. but it has also only given me back one answer for each individual case, if you see what i mean!

Any ideas?

Dave

timster

3:38 pm on Sep 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check out the "GROUP BY" clause for tallying things like that. Here's an example:

select theField, count(theField) AS theTotal
from theTable
group by theField
order by theTotal DESC