MySQL count specific rows - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL count specific rows (
/showthread.php?tid=426295)
MySQL count specific rows -
dusk - 28.03.2013
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?
Re: MySQL count specific rows -
Scenario - 28.03.2013
http://dev.mysql.com/doc/refman/5.1/...ting-rows.html
Re: MySQL count specific rows -
eesh - 28.03.2013
SELECT Level FROM 'table' Where Level=2
count=mysql_num_rows();
Re: MySQL count specific rows -
dusk - 28.03.2013
Thankyou guys. Another question: can I add info to an existing field. "UPDATE" changes the data,doesn't it?
Re: MySQL count specific rows -
Vince - 28.03.2013
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;
Re: MySQL count specific rows -
dusk - 28.03.2013
That's great Vince,now, what if I need to add text info?
PHP код:
UPDATE table SET field = field + string;
Would this work?
Re: MySQL count specific rows -
Vince - 28.03.2013
I'm not sure. But there is a CONCAT() function that you can use.
Re: MySQL count specific rows -
dusk - 28.03.2013
Tell me more about CONCAT,please
Re: MySQL count specific rows -
Scenario - 28.03.2013
http://dev.mysql.com/doc/refman/5.0/...unction_concat