SQL Query Help

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
truepal20032001
Forum Commoner
Posts: 27
Joined: Mon Jun 25, 2007 8:28 pm

SQL Query Help

Post by truepal20032001 »

can some one help me word a sql query that selects the total amount of columns in the table, ex:

====================================
id | text | text 2 |
====================================
1 | dddf | dddd
________________________________________|

2 | dddf | dddd
________________________________________|

3 | dddf | dddd
________________________________________|

4 | dddf | dddd
________________________________________|

^
||

I want it to output 4
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That's number of rows/records.

The COUNT() function may be useful.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

I assume, as did feyd, that you mean rows, not columns. If so, I would just do something like:

Code: Select all

...
$result=mysql_query('SELECT * FROM xxx');
$nr=mysql_num_rows($result);
Post Reply