MySQL count specific rows
#1

Hello,
Let's say i have a Field named Level. How can i count how many rows are there which contain "2" in that field? Is it possible?
Reply
#2

http://dev.mysql.com/doc/refman/5.1/...ting-rows.html
Reply
#3

SELECT Level FROM 'table' Where Level=2

count=mysql_num_rows();
Reply
#4

Thankyou guys. Another question: can I add info to an existing field. "UPDATE" changes the data,doesn't it?
Reply
#5

Despite the syntax of SQL, the SELECT clause is pretty much the last thing that gets evaluated in a standard query. So:

PHP код:
SELECT COUNT(*) FROM table WHERE level 2
Edit:

The field's contents are available to you during the query. Something like this works fine:

PHP код:
UPDATE table SET field field 1
Reply
#6

That's great Vince,now, what if I need to add text info?

PHP код:
UPDATE table SET field field string
Would this work?
Reply
#7

I'm not sure. But there is a CONCAT() function that you can use.
Reply
#8

Tell me more about CONCAT,please
Reply
#9

http://dev.mysql.com/doc/refman/5.0/...unction_concat
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)