Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




SELECT COUNT(*) Or SELECT .. LIMIT 1?


If the purpose of a query is to see if atleast 1 record exists which would be faster?

SELECT COUNT(*) or SELECT .. LIMIT 1?

Both would use a WHERE clause.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Count(*) In A Select Returns "1". It Should Behave Like Select Count(*)
i'm trying to make a query work properly but I got lost:

SELECT *,count(*)
FROM cancons c, musics m, discos d, r_discos_cancons rdc
WHERE c.c_id_music = m.m_id
AND rdc.rdc_id_disc = d.d_id
AND d.d_id_music = m.m_id
AND m.m_id = 24
GROUP BY c_id

note:
cancons (ca) = songs (en)
discos (ca) = cd's (en)
music (ca) = musician (en)

don't worry for the WHERE part. i need it because of the foreign keys.
this query returns a table with the title of the song and some more data. on the right side, I get another column called "count(c_id)" with the number "1" in it for each row. That's supposed to be due to the "group by" clause, I think.

I'd like to get the table with the songs, as usual, and, with the same query, I'd like to get the total number of rows selected.

Select Query With Limit Same As No Limit?
I have a question, EXPLAIN on a SELECT query seems to return the same as explain without doing a limit.

Here is a dump from my console:

Select Limit
I have a list of numbers (i.e. 1 to 175) and I want to do a select statement to
get the highest number. I have tried the limit thing but not getting the right output. Can someone shed some light on this?

SELECT Without Specifying LIMIT
mysql version: 3.23.58 (i have to live with it, my customer's IT Manager is a stubborn donkey)it took me a while to figure that out, but my script fails because it is actually selecting too many data at the same time apparently.so if i do a "SELECT id FROM myTableWithManyRows" the page returns blank (no error displayed )

but if i do "SELECT id FROM myTableWithManyRows LIMIT 0,1000" it works.

but i need to be able to select 5000 records at once (only their id) !!

Is there a setting i can change in mysql or php in order to make this work?

SELECT With More LIMIT Options ? How ?
I have two elements : one with cars and other with boats - in the same table.
I want to make one select statement that returns the first 7 cars ( random selected ) and another 3 boats ( random selected ).
I am searching from 2 days.


Using LIMIT With SELECT Queries
I have a problem using the LIMIT statement in MySQL. Basically I want to limit results to a number such as 200. However, this works fine except it returns the *first* 200 records it finds. What I want is the *last* 200 records because I need to examine the latest records.

here's an example of how the query looks now:

SELECT recordid FROM allRecords WHERE userID = $uID ORDER BY recordid LIMIT 0, 200

What do I need to change/add to make it pull the latest records and not the first 200?

Select Into Outfile And 2Gb Limit
"select into outfile" stops writing to file at 2Gb size... Where i can turn it off?

Limit HAVING Without Limiting SELECT
I have three tables that I am joining to display some simple statistics.  The query I have no is working great, but I need to limit the aggregate functions by date.

The first table is ghall, which has some information about ghall objects.  There are eight records in the table and it remains petty static.

The second table is ghnotes, which is just a table with an id and a fulltext field holding a note about each ghall object.  The relationship is one-to-one.  The id of this table maps to an ID field in the ghalls table.

The third table is a table of game matches.  This is essentially the meat of my app and it holds a record of each match in a game.  One of the fields is the id of the ghall the match is played in.  The statistics are gathered from this table as well, including wins, losses, elapsed time, and errors for each match.

What I want to do is collect the statistics from the match table for a certain date range and return the results for each ghall object.  If there are no records matching a certain ghall, I still want the data returned from the ghall table's record, but with a zero for each stat.  When I add a HAVING clause to my query that specifies a date range, I get strange results.  Here is the working query without a date range: Code:

SELECT And LIMIT Question
I have multiple queries like this:

SELECT col1, col2, col3, col4 FROM table1, table2
where table1.col1 = table2.col1 and table1.col2 = 1
ORDER BY col3 desc LIMIT 5

and

SELECT col1, col2, col3, col4 FROM table1, table2
where table1.col1 = table2.col1 and table1.col2 = 2
ORDER BY col3 desc LIMIT 5

The only difference is in the WHERE clause table1.col2
= x.

I would like to have one statement instead of multiple
statements and though about using IN clause like:

SELECT col1, col2, col3, col4 FROM table1, table2
where table1.col1 = table2.col1 and table1.col2 IN
(1,2,3) ORDER BY col3 desc LIMIT 5

It works without LIMIT, but I need to use the LIMIT.


Limit The LAST Lines Of Select
I need to get only the last x lines from a select query (maybe 10 lines out of some 100's).

How can I simulate the LIMIT clause for this purpose?

My query:
SELECT *
FROM table1
WHERE account_id = 3 AND user_id = "username"
ORDER BY mail_time;

Select Query Using Limit
i have the basic sql query as follows:

$sql = "select * from photo where CategoryId='$idc' order by Id limit $start, 9";

this will select all rows from db photo based on CategoryId, then stop after it gets the 9 beginning at $start right?

start is the value of the ID i want to start the select from. in this example, i have valid db values ranging from id: 11-20. the 1st page that runs this query has start=11, and displays for 11-19. when i goto the next page setting start=20, i get nothing. Limit returns 9 rows starting at $start right? or am i misunderstanding how all this works?

Best Index For Select With Where/order/limit
CREATE TABLE `db`.`messages` (
`unixtime` int( 10 ) NOT NULL default Ɔ',
`username` varchar( 20 ) NOT NULL default '',
`sender` varchar( 20 ) NOT NULL default '',
`content` mediumtext NOT NULL ,
KEY `username` ( `username` ) ,
KEY `unixtime` ( `unixtime` )
) TYPE = MYISAM ;
This is the kind of select that will be used a lot :


SELECT unixtime,poster,content FROM messages WHERE username='$name' ORDER BY unixtime DESC LIMIT $x,10
username has an index on it, because of the WHERE part. Unixtime has a time(); value in it wich I use to display the date, and because I also use it for ordering by date it also has an index.

I dont think this current setup is wrong, but it could be improved, and I want to know if the following things are right :

I could add an 'id' int (10) column, and set it to auto-increment and primary key and drop the key on the unixtime column. That way the messages will already be stored by date (new messages will always get a higher id value), and for mysql it will be easier to find the 10 posts that I want. I can not simply change 'unixtime' to a primary key, because on busy moments there is a real chance two users might send a message at the exact same second, resulting in a non unique value for that column.

SELECT unixtime,poster,content FROM messages WHERE username='$name' ORDER BY id DESC LIMIT $x,10
It will use the key of username to find all messages for this person, and it will then use the primary key to just select the 10 messages that are wanted. Those messages are already ordered by id (thus by time) when reading them so it will not need an extra sorting process ? unlike the ordering by unixtime wich probably requires all rows of that person to be read, and then all of them to be sorted to find the 10 that are wanted. So ordering by primary key would be faster and/or use less memory ?

I could go even further and also drop the key on username, and instead have one primary key consisting of ('username','id') , with the id still an auto-incrementing INT. This way there is only one index that has to be loaded, wich can be used for both the WHERE and ORDER BY.

The table would be like this then :

CREATE TABLE `db`.`messages2` (
`id` int( 10 ) NOT NULL AUTO_INCREMENT ,
`unixtime` int( 10 ) NOT NULL default Ɔ',
`username` varchar( 20 ) NOT NULL default '',
`sender` varchar( 20 ) NOT NULL default '',
`content` mediumtext NOT NULL ,
PRIMARY KEY ( `username` , `id` ) ,
) TYPE = MYISAM ;
I have done some testing , and used 'explain' too. With my first table it uses the username key and a filesort, on the second with the double primary key it reads a bit more rows, but its not using filesort anymore... so that should be an improvement ? I think it is, but would like some confirmation before I change it on dozen tables in the live database. And are there any other changes in index that would be even better ?

Limit Field Length Of Select *
I have this table with a lot of fields in it. A few of the fields are text-blobs, so select * from tableG is pretty unreadable. Is there a way to select *, but truncate all columns to X characters. I realise, that I could type out the fields explicitly, but I'm after a quick trick to use in the command line client.

Optimizing A SELECT .. WHERE .. LIMIT Query
(using MySQL 5.0)

First, the problem: I need to select different "pages" of IDs that match a small list of categories.

Here's my table:

CREATE TABLE `testTable` (
`id` int(10) unsigned NOT NULL auto_increment,
`category` tinyint(3) unsigned NOT NULL,
`username` char(15) NOT NULL,
PRIMARY KEY (`id`),
KEY `cat` (`category`)
) ENGINE=MyISAM AUTO_INCREMENT=1000001 DEFAULT CHARSET=latin1
And an EXPLAIN of my query:

EXPLAIN SELECT * FROM myTestable WHERE category IN(5,8,11) LIMIT 5000,20;

id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra
1 | SIMPLE | myTestable | range | cat | cat | 1 | null | 49904 | Using where
So from that we can see it's hitting 50,000 rows to get the 20 rows that I want (it's a table with 1,000,000 rows total).

I've been using MySQL for a fair amount of time, but I haven't ever done much optimization beyond the standard "add an index on it".

Using A Variable With LIMIT In SELECT Statement
Is it possible, either directly or with a decent workaround to perform a LIMIT on a SELECT statement using a variable?

For example, I want the top N results, where N might be passed in to a stored procedure, or even issued from the command line...

CREATE PROCEDURE `xx`(IN N INT)
SELECT * FROM `Candidate` LIMIT N;

This fails at 'LIMIT N' because, apparently, LIMIT has to be followed by a literal constant.

Is there a way to do this, or do I need to construct the SQL in my client and give up on using a stored procedure whenever I need a variable number of results?

SELECT Problem Using GROUP BY And LIMIT
I have a SELECT that returns with multiple records - It works when I have a
LIMIT clause but when I try to include a GROUP BY clause, the select returns
nothing (ie no records, no errors).

The GROUP BY specifies a column that does exist in my db (and is also the
only field that is select from the db).

Where am I going wrong? Because my select uses hashes (which I provide with
PHP - they are not created by MySQL) I've tried to simplify my query below,
keeping the statements the same but my values abbrieviated. Code:

Using Limit With Select Or Update Command
How come I can do:

select field1 from database limit 10
*shows first 10 records like it should

select field1 from database limit 1,5
*It returns first 5 rows correctlly

update database set field1='first set" limit 10
*It correctlly updates the field for the first 10 records

update database set field1="top 5" limit 1,5
*I get an error that says problem with limit at ^5 check command for correct syntax

Is there different syntax for limit when using with a select statement Vs. an update command?

Select Union Order Limit
I must select all the rows of a table and sort them in decreasing order by insertion date. The first rows that must be printed should have a certain value in relation with the user_id

this is my table:

user_id - user_regdate - username

1 - 1000 - fabio
2 - 1300 - andrea
3 - 500 - alessandro
4 - 300 - pippo
5 - 900 -chiara

i must get

5 - 900 -chiara
3 - 500 - alessandro
4 - 300 - pippo

2 - 1300 - andrea
1 - 1000 - fabio

i succeeded with this query

$query_singles_on = "(SELECT user_id , username, user_regdate FROM `phpbb_users` WHERE `user_id` IN(3,4,5) ORDER BY user_regdate DESC)
union
(SELECT user_id , username, user_regdate FROM `phpbb_users` ORDER BY user_regdate DESC) LIMIT $start,$step";

and locally, on mysql 4.0.15 it works perfectly and without glitchs.
problem is, remotely, on a 4.1.11a-4sarge7 doesn't work and I get this (wrong) result:


3 - 500 - alessandro
4 - 300 - pippo
5 - 900 -chiara

1 - 1000 - fabio
2 - 1300 - andrea

: they are not sorted by decreasing user_regdate.

Limit Text Output In SELECT Query
I'm looking to output a list of news stories, but only outputting the first 100 or so characters of the text and only limited to the newest 4 entries in descending order.

At the moment I'm using this nugget: But it doesn't work.

$result=mysql_query('SELECT newsheading, (LEFT newsbody,100), newsdate FROM news ORDER BY newsid DESC LIMIT 4');

Limit On Select Produces Records Out Of Order
I have a Java applet that displays descriptions (from an sql table) in a text area. The latest description is shown on load-up with max(time) ok, and there is a button to step through them in reverse order from latest to earliest.

I have a problem with the following query:

SELECT idescription FROM descriptions where unit = 'A' and iname = 'plate' order by 'time' limit "+nextrecord+",1

This query is executed on a java button press. The variable 'nextrecord' has already been set to 1 (to get the second latest, i.e. 'very useful item') and then 1 is added to it each time the button is pressed to get the next previous one. But the resulting order is squiffy, e.g. when applyed to the following table Code:

How To Select Count(*) And Something Else?
How do you select a count and another field without having to do two queries?

here's the query I'm using:-

SELECT
count(*) as totals, user

FROM user_posts
WHERE post='$md5'

SELECT COUNT
I'm counting rows from a mysql database able and trying to display the count. I have the following.

$count = "SELECT COUNT(*) AS newcount FROM stores";
$cr = mysql_query($count);
if (!$cr)
die(mysql_error());
if($cr){
//Make site ID now ...
$var1 = $newcount;
$var2 = P00;
$var3 = $var2.$var1;
}

The problem I have is thet $newcount seems to be empty. I have used count and not put "AS newcount" in the query but that made no difference. I have tried to echo the $newcount but again it is empty. Now, in PHP is there something else I must do to return the value of $newcount that I have missed?

SELECT Count
how to use SELECT Count.

Select *, Count
I want to perform a select query, but it doesnt return the data i have in mind. The result should be all info in 1 row with the highest date plus a total of game_id
This is what works best sofar.

SELECT * , COUNT( game_id )
FROM `battle`
WHERE game_id =4
GROUP BY game_id
ORDER BY b_date DESC
LIMIT 1

Yet this doesnt return the last date but the first. Everything else i tried the count function returned 1 even though it should be 20 for example.
How can i solve this?

SELECT COUNT(*)
I heard SELECT COUNT(*) can take a lot of resources if your counting a table with lots and lots of rows (hundred thousands, millions).
What if you add A WHERE clause to it? So something like:
SELECT COUNT(*) FROM table WHERE pid = ?
(pid is a index too btw)
IF adding a where clause, does it still scan the entire million plus rows, or only scans what is returned from the WHERE clause?



SELECT COUNT Or SUM()
Is there a difference between these two functions when your trying to gather how much a item appears in a database?
For example, which one will be better for a database w/ ~150,000 rows.

SELECT COUNT(category_id) FROM Threads WHERE category_id = '2'

Will return ~50,000 rows matching category 2

OR

SELECT SUM(category_id = '2') AS total FROM Threads
total will be ~50,000 rows also.

Select Count
I need to do the follow SQL..PHP Code:

 SELECT COUNT(t.id), COUNT(p.id) FROM threads t, posts p 

and add the two counts together... within the SQL query can i do this?
or do i just have to return the arrays and added the results seperatly.

Select Count Where Entries Are < 4
I want to count how many users have 4 or less entries in the table, so, so far i have
SQL
SELECT COUNT (*) AS fourLOCS FROM
(SELECT DISTINCT locsLog.locStudentID FROM locsLog)
which counts all the entries in the locsLog table and groups them by studentID so tells me how many users have made entries.
How do I limit this so it only gives me a total number of users who have made 4 or less entries. I think I'd need WHERE after the nested SELECT statement, but I don't know what I'd put in it. I tried
SQL
SELECT COUNT (*) AS fourLOCS FROM
(SELECT DISTINCT locsLog.locStudentID FROM locsLog)
WHERE fourLOCS <= 4
but had an error message (I'm doing it with an Access database with ASP and the message was 'Too few parameters. Expected 1').

Select Count(*) Timing Out
I'm doing a "select count(*) from table1" and it takes forever, more then 3 minutes, for the result to come back. I'm running MySQL 5.0.19 on RedHat, I know my table has 51M records. When I run a "show table status where name='table1';" it returns the results in a few ms and gives me a record count. My table is defined below, I've tried forcing use of each index individually and forcing no indexes and all combinations and always the same result. Server is an intel based 64bit cpu with 16GB ram with pretty much nothing else going on......

Select Count(*) Issue
I have what I think is a simple SQL command getting unexpected results.

PHP code:

$query = "select count(*) as total_rows from part_master where mfg_id = '933' and part_no = '3601' order by part_no";

$result = mysql_query($query);

The result is total_rows = 0.

I run the same SQL from the DOS command window and get:

mysql> select count(*) as total_rows from part_master where mfg_id >= '933' and
part_no = '3601' order by part_no;
+------------+
| total_rows |
+------------+
| 1 |
+------------+
1 row in set (0.01 sec)

I'm running the latest versions of Apache, MySQL and PHP on a WinXP box.

Select , Count(*) In MySQL
I write the following code in vb6 its work fine for Access and MSSQL but not work with MySQL, RecordCount return -1 always kindly help me..

Dim mms As ADODB.Connection

Set mms = New ADODB.Connection
mms.ConnectionString = "DRIVER = MYSQL ODBC 3.51 Driver;SERVER=10.48.60.183;DATABASE=mms;UID=kma;pwd=abcd
mms.Open

Set rstIWOrder = New ADODB.Recordset

SelectString = "select * from IWOrder where WON ='"
SelectString = SelectString + txtIWO.Text + "'"
rstIWOrder.Open SelectString, mms, adOpenStatic, adLockReadOnly

If rstIWOrder.RecordCount = 0 Then
MsgBox "Internal Work Order not Found in Database"

else

or

SelectString = "select count(*) from IWOrder where WON ='"
SelectString = SelectString + txtIWO.Text + "'"
rstIWOrder.Open SelectString, mms, adOpenStatic, adLockReadOnly

SELECT COUNT (*) FROM Table
Newbie: SELECT COUNT (*) FROM table

When I run the above query from the command line, it works
fine.

When I run it from my powerbasic program, I can't seem
to get a reasonsible result.

What type of result does count return?
I get something that looks like this:
[ CHR$(133) ][ CHR$(21) ][ CH...

and the type is given as -5...

What is this type?

Php, Mysql And Select Count
I use as the base an existing system, called PHPNuke. My programming work before are only on Assembler, C, C++, Perl and other Databases than MySQL. In PHPNuke and/or the MySQL Queries contained in it there are sequences for simple counting rows (without further processing). The following sequence is permanently used (as example):

$result = $db->sql_query("select * from "$prefix."_sometable where someting='$foo'");
$numrows = $db->sql_numrows($result);

I would make it rather in such a way:

$result = $db->sql_query("select count(*) as count1 from "$prefix."_sometable where someting='$foo'");
$numrows = intval($db->sql_fetchrow($result['count1']));

Now my hopefully not too stupid question. Is there a reason, why e.g. in MySQL large genuine result quantities must be formed, only in order number of lines to determine? I worked so far actually only with other databases. But it is quite possible that that makes any sense here - who knows? Knows here someone the mystery solution?

SQL - Select Where Count Equals Zero
I have a table of products and a table of ratings so people can rate the products. I would like to select all the products the user has not rated. My thoughts are to join and count returning rows where count equals zero. But I am just not sure how to do it.

I have this that does the exact opposite of what I need, this returns just the row that I rated, I need all but the rows I rated, Make sense?

SELECT products.*, COUNT(ratings.id) AS count FROM products
LEFT JOIN ratings ON ratings.rateable_id=products.id
WHERE ratings.user_id = 10
GROUP BY products.id

(10 is the hard coded user id)

How can return ALL except the rows I rated?

Select Count(*) > @foobar
i have a query as follows and is unsure whether it is mysql or php:

$result = mysqli_query("SELECT COUNT(*) > @foobar AS status ....") where
it's suppose to get a one row value of either '0' or '1' (false or true)

if i were to do a SELECT COUNT(*) FROM...
i can use the php $row["COUNT(*)"] to refer to the index.

if i were to do a SELECT COUNT(*) AS status FROM...
i can use the php $row["status"] to refer to the index.

but in this case SELECT count > @foobar AS status,
refering to $row["status"] gives a empty value. however, running the
same query in mysql command prompt produces

+------+
|status|
+------+
| 1 |
+------+

php doesn't support such select statement? even array_keys($row) returns
empty.

Select COUNT(Name) Into PCount
i wanna count the total number of records by using this sql query...
Select COUNT(Name) into pcount from agent where agentcode = 'abc123';

this return me the total number of all records...

but when use this query:

Select COUNT(Name) into pcount from agent where Name = 'goh';

it return me the correct result....

may i know what is the problem and how can i solve it ??

Select Count Problem
I have two queries that I want to combine.

select Count(flag) as Good
from table
where
flag = 'G'
Group by Fruit

select Count(flag) as Bad
from table
where
flag = 'B'
Group by Fruit

COUNT (*) Inside Select
I am doing something wrong i would like to do a count inside this select for example:

SELECT th.tid, th.tname, th.tmain
(SELECT COUNT(*) as postnumber FROM forumpost AS post WHERE post.ptid=th.tid)  
FROM thread as th WHERE tmain=1

Select Statement With Count
I want to know how many different etries there are in one column. My table: pics{id, pic_name,category} There are many pics inside, but only a few different categories, e.g. (outside, inside, garden). Now I need a Select count on this column, and for the example above the result shoud be "3" - 3 different categories

"SELECT DISTINCT COUNT(category) FROM pics"
delivers a much higher number, it counts all rows of the table.


Slow Select Count(*)
I have a table with 75,000 rows.

An Explain tablename shows this

'TourPartsID', 'int(10) unsigned', 'NO', 'PRI', '', 'auto_increment'
'TourPartID', 'int(10) unsigned', 'NO', 'MUL', '', ''
'TourPartTypeID', 'int(10) unsigned', 'NO', 'MUL', '0', ''
'Language', 'int(10) unsigned', 'NO', '', '0', ''
'XML', 'mediumblob', 'NO', '', '', ''

When I do a Select count(*) from table, it takes about 12secs to return my number. This is occuring in the QueryBrowser and from the .NET library when it calls the Stored Procedure that does the Select count(*)....

My only quess that is my last column is a MEDBLOB but since I am NOT indexing that, I would figure MySQL ignores it.

Select Count Syntax
im just a begginer in mysql. I have a problem on how can i place a result of a select statement query in a variable.
Here my select statement:
Select count(employee) from employee where empmonth =
1 and empyear = 2005;
This syntax is ok, it return a result of 123894 records. But what I want is to place the result in one variable that i can access inside the program so that i will run this select statement only once. I have tried this one syntax:
Select count(employee) into ll_count from employee
where empmonth = 1 and empyear = 2005;
but it return a result of zero record.

Two Table COUNT/select
I need to count the total (using SUM) from one column in one table, where the a condition is set from another table.
so far I've been striking out with this:
Code:

SELECT maxbid SUM(maxbid) FROM `probid_auctions` WHERE probid_categories.parent = 1853

Select From Table And Count Results In Another
I have to tables table one containing airports and table two containg bookings. What I need to be able to do is count how many rows are returned form the booking table that matches each airport in the airport table.

So I might have in my airport table
Newcastle
Heathrow
Standstead
etc etc

and in my bookings table I have

Newcastle
Newcastle
Standstead
Heathrow
Heathrow

And what I want returned is
Newcastle(2)
Standstead(1)
Heathrow(3)

How can I go about doing this.


Select Query With Character Count
can you help me with creating a select query where the character count in a specific column is more than, say, 20 characters?

Doing A Select Statement With An Array To Get A Count
I posted this in the php forum and it was suggested I try it in the MySQL area instead. Sorry if this gets posted more than once.

So here is my problem. I have a series of mysql queries to allow users to set filters for the data that is returned. They are searching for clients (Site_ID) with projects (Request_ID). A single client can have multiple projects. I want to be able to count the number of projects that are returned from a query. Here is the tail end of that code...

Multiple COUNT() In SELECT Statement
SELECT
COUNT(s01_Products.id)
FROM
s01_Products
LEFT JOIN
s01_Attributes
ON
s01_Attributes.product_id = s01_Products.id
LEFT JOIN
s01_Options
ON
s01_Options.attr_id = s01_Attributes.id
WHERE
(
s01_Products.active = 1
) AND (
(
LEFT(s01_Options.prompt,5) = "Small"
) OR (
LEFT(s01_Options.prompt,2) IN (28,30)
)
)


SELECT
COUNT(s01_Products.id)
FROM
s01_Products
LEFT JOIN
s01_Attributes
ON
s01_Attributes.product_id = s01_Products.id
LEFT JOIN
s01_Options
ON
s01_Options.attr_id = s01_Attributes.id
WHERE
(
s01_Products.active = 1
) AND (
(
LEFT(s01_Options.prompt,6) = "Medium"
) OR (
LEFT(s01_Options.prompt,2) IN (32)
)
)
And one for Large and Extra Large...

I would obviously like to combine all 4 queries in to 1 so that I can get my 4 counts in a single,

SELECT COUNT Syntax Error
Have a syntax error with the following query ...
SELECT number COUNT(*) AS vessels FROM process_fleet WHERE uid=1
No idea what is wrong with the sytax... can only one see what I'm missing?

Question About Select Count(*) With Group By
suppose a hypothetical table called 'table' with one field called 'field' of
an arbitrary type.

select count(*) from table where field='value' group by field

produces no rows when run under the latest mysql. without "group by" it
produces 1 row.

is this according to the SQL standard or is this just a coincidence? in
other words, can i rely on this behaviour to deduce that there are no fields
with value 'value' in 'table'?

Select Count From A List Of Digits ??
I'm using php to extract data from postgres and print to browser. I have data that was input through checkboxes on a form - each checkbox had a different value but got pushed into the same column. Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved