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




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.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
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?

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

Caching Results For Large Multi-table Select
I'm developing a site that may eventually have a very large database of
users (hopefully, but who knows). Often there will be queries with multiple
joins and sometimes may include a few fulltext searches. Each page of
results will have a limited number of results displayed (obviously). As I
understand it, MySQL caches only exact queries, so doing a LIMIT (x,y) on
each query to get results for the specific page will cause MySQL to run the
entire query again, instead of pulling from the cache. I will limit the
results to 1000, but what's the best way to limit results per page?

I was thinking that I could run the SELECT and LIMIT to 1000, then to a
mysql_data_seek to jump to the starting row for the page and fetch a certain
number of rows for the page. For each page, the exact same SELECT would be
used and therefore the results would be cached.

'order By Alternating Table' Results And 'begins With' Select
I am just starting to learn SQL and have been working on a couple of questions and yes this is homework related. I am having trouble with 3 questions. I have the basis for the answers but am stuck on a couple of points.

I don't expect a direct answer but a push in the right direction would be helpful. Also, if anyone can recommend additional resources for assisting with learning SQL, that would be great. The first question is as follows:

A company is preparing invitations to its annual holiday celebration and wants to invite its sales staff (everyone in the SALESREPS table) and its customers (everyone in the CUSTOMERS table). Write a SQL statement that returns output looking like the following (including the sort order): Code:

Slow Select Using Count(distinct) In A Table Bigger Than 100000 Records
Recently I started using MYSQL in my enterprise. I made a table which has around 100000 records. The problems is that it is really slow.. Im trying to do a query in which I get the number of distinct users per day.

This is my query:

select date(startedDate) as mydate, count(distinct(Users)) as users from Mytable
group by mydate

It is really simple and it does it correctly but it takes one minute.. One minute is not too much time but i need to insert around 10 000 000 records and thats what worries me.....

All Results Of A COUNT
The following query works as I need it to, except that 'kingdom's that don't have any associated 'territory.tile's do not get included in the results.
Code:

SELECT name, gold, COUNT( territory.tile ) AS land
FROM kingdom
LEFT JOIN structure ON structure.kingdom = kingdom.name
LEFT JOIN territory ON structure.id = territory.structureID
GROUP BY kingdom
ORDER BY gold DESC
LIMIT 0 , 20

What do I need to change so that all 'kingdom's are included in the results, whether they have associated 'territory' or not?

Count Results
does there exist a less resource intensive way on how to count the results of a query? I mean I know that way: Doing a query on mysql and then using mysql_num_rows for fetching the amount of results, but I guess there should be an easyer way, that probably uses a mySQL syntax for that? Probably COUNT()? I read through the explanation of it and believe this could be the way how to do, but I can´t figure out how exactly the syntax would look alike

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 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.

Results Of A SELECT SUM
I am trying to figure out how to use the results of a SELECT SUM using Java (which I know very little about)


rs = databaseStatement.executeQuery ("Select sum (unitcost) as total from subcomponents")

The query seems to run correctly

so, I now say
System.out.println (rs.getString("total"));
or
System.out.println (rs.getDouble("total"));

and the result is

java.SQL.SQLException: Before start of result set

What am I missing.

Limiting The Results In SELECT
I could not find where it is written, so I want to ask if MySQL can do this.

In the event I want to not select a few columns is there a way I could say something like:

SELECT * (but exclude col_08 and col_99) FROM table

or would I have to list all 98 columns I wanted to exclude the two I don't want?

SELECT Results After X Rows
I am trying to run a league creation script using php and mysql. I was thinking that i could do it by getting every user into one column and then pair them off by starting from the second result found and place that with the first user in the first fixture row. For the next fixtures i would place the 3rd result found in a row with the initial users.

This way i make sure they dont play each other twice and each fixture created in unique.

Is their a mysql function to do a select query but dont have it start outputting the results until it reaches a certain row from the results? I will also need it to go back to the first result found once it reaches the end of the results.

Limiting SELECT Results
I would really appreciate any thoughts anyone might have on how to solve this problem below. We use MySQL 4.0.22 so the 4.1 subqueries enhancement is not available to us.

CREATE TABLE t1 (char item_num(12), int member, char parent_item_num(12), int search_fld);
INSERT INTO t1 (item_num, member, parent_item_num, search_fld) VALUES ('AAAA', 0, '', 2);
INSERT INTO t1 (item_num, member, parent_item_num, search_fld) VALUES ('BBBB', 1, '', 2);
INSERT INTO t1 (item_num, member, parent_item_num, search_fld) VALUES ('CCCC', 2, 'BBBB', 2);
INSERT INTO t1 (item_num, member, parent_item_num, search_fld) VALUES ('DDDD', 2, 'CCCC', 2);

How do I:
SELECT FROM t1 WHERE search_fld = 2 AND
no records that have a parent_item_num equal to an existing item_num.
In other words it would select records with the item_nums of AAAA, BBBB and DDDD above (not CCCC).

It's making me feel dumb and I even went to the extreme of creating temporay tables but did not find an efficient want to do this in a large, very active database.

Many To Many Select Using DISTINCT Or Not Return The Same Results
I was on MySQL website looking for an answer, but still need assistance please.

I want to do the opposite of the following:

SELECT * FROM myTable WHERE id IN(1,2,3,4,5) ;

I want to use my array(1,2,3,4,5) to exclude items in the result set, not include them.

So, I want to do something like this:

SELECT * FROM myTable WHERE id NOT_IN(1,2,3,4,5) ;


Ordering Select Results By Column
I have a table with three text columns and one time column (say text1,
text2, text3, and time). I wrote a query to select the rows where any
of
the text columns contains a certain keyword:
select * from table1 where
text1 like 'keyword' OR
text2 like 'keyword' OR
text3 like 'keyword';

Now I need to order the
results so that rows associated with text1 are listed first, then
text2,
then text3; and also have the results from each column sorted by
time. Is there a way to do this in mysql?

Can SELECT Return The Position Of The Results?
I have a table with values:

Row: Name Row: ID
John 4890
Mark 4922
Peter 4934
John 4980
Joe 5029
Lisa 5044
etc...

What I need is a query that I would do for example on John (name='John') that would return the following:

location
1
4

In fact the only thing I need is the location of the John in the resulting table. Apart from the Name column I do have other column of ID's. They are incremental but not step 1 if this can help in any way. Is something like that possible with one query?

No Results With SELECT Using INET_NTOA & INET_ATON
Why am I not getting any row when in fact there are several records in the db?

// `user_ip` int(10) unsigned NOT NULL default '0',

$query = query_db("INSERT INTO online_users (user_ip, time_stamp)
VALUES (INET_ATON('".addslashes($user_ip)."'),
'".addslashes($timeout)."')");

/* ... code code code ... */

$query = query_db("SELECT * FROM online_users
WHERE (user_ip = INET_NTOA('".addslashes($user_ip)."'))");

echo mysql_num_rows($query); // always 0

Select Distinct Results Without Throwing Away Data?
id series_id image date
6 2 1191956895.jpg 2007-10-09
5 3 1191956773.jpg 2007-10-09
4 2 1191451083.jpg 2007-10-03
3 1 1191451026.jpg 2007-10-03
2 1 1191451012.jpg 2007-10-03
1 1 1191450488.jpg 2007-10-03

if you take a close look at the code above you might be able to see that i have these images assoicated with one of 3 series. id like to be able to select the most recent from each one and discard the rest. however a command link distinct on the series_id throws away all the other data around it that i need.

the results would look more like

seires_id image
2 1191956895.jpg
3 1191956773.jpg
1 1191451026.jpg

i imagine this would be much like a forum sorting the most recent topics posted in a forum by finding the most recent posts for each distinct topic.



Big SELECT: Ordering Results By Where Matches Are Found
I'm sure there must be an accepted technique for this, but it's something I haven't tried before, so if anyone can point me in the right direction I'd be grateful.

I'm writing a search facility for a site where the data is stored in several tables - let's say 5 for this example - and I want to order my results according to where (if anywhere) matches are found. So...

Let's say I have tables 'speakers', 'topics', 'speakers_topics', 'articles', 'other'.
'speakers' is a table of speakers, with id, name and some text fields.
'topics' is a list of topics they address
'speakers_topics' relates the above two by pairs of id numbers
'articles' and 'other' are further tables of text data with possibly more than one row for some speakers, identified by id.

I want to search the data in the following order:
name from 'speakers'
topics
text data from 'speakers'
text data from 'articles' and 'other'
...and order the results according to where in that hierarchy a match is found.

So, if the user's search term matches one speaker's name field, another's topic and someone else's text data, that's the order in which the results should be ordered. Also, if the same person is matched from, say, both name and text fields (which is very likely, as their name will almost certainly appear in some of the text), the name should take precedence in the ordering.

To complicate matters further, I'd like if possible to extend this to an and/or situation. If the user enters two or more words, any results that match all the words should be ordered above those that match only some of the words.

I can probably do this relatively easily with a series of separate queries (I'm doing all this from PHP, by the way), but that strikes me as inefficient.

Join Results From Select Multiple Statment
how I can join results from multiple queries in one result without geting a prodict of the tables

ex:
table1_Col1, table1_Col2, table1_Col3...table2_Col1, table2_Col2, table2_Col3...table3_Col1, table3_Col2, table3_Col3...
table1_Col1, table1_Col2, table1_Col3...table2_Col1, table2_Col2, table2_Col3...table3_Col1, table3_Col2, table3_Col3...
, , ...table2_Col1, table2_Col2, table2_Col3...table3_Col1, table3_Col2, table3_Col3...
, , ... , , ...table3_Col1, table3_Col2, table3_Col3...
, , ... , , ...table3_Col1, table3_Col2, table3_Col3...


using the 4.0 sql so no subqueries supported.

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 DISTINCT Unexpected Results With Multiple Columns
SELECT DISTINCT (query) FROM `data` WHERE 1 LIMIT 0 , 30
and it works fine. When I start selecting more than one column, though, it returns all the rows weather the query is distinct or not. Here is the query that doesn't work.

SELECT DISTINCT (query), data. * FROM `data` WHERE 1 LIMIT 0 , 30
It seems like DISTINCT() is looking for a completly distinct row. How can I get it to just look for a single distinct column?

MYSQL SELECT Statement Depening On Search Results
I have a search form that contains 3 dropdown boxes:

- search_bedrooms
- search_price
- search_area

Each of these boxes contain values which will get info from a database when submitted, but they also have a value called [no preference], this is selected when the user doesn't want to search for any particular value.

When submitted it goes through to a page which has a MYSQL SELECT statement:

$query = "SELECT * FROM property_details WHERE area = '$search_area' AND price = '$search_price' AND bedrooms = '$search_bedrooms'";
What I need to know is if the user selects [no preference] on any one of the dropdowns, how can I make the above SELECT statement not include that in the search, but still search on the other criterias.

(e.g. if in the search_bedrooms dropdown I selected [no preference], how could it be excluded from the search, but still include area and price?)

I know it can be achieved with multiple SELECT statements,

SELECT DISTINCT On A Single Field - Full Row Results
I've been trying to figure out how to do this and can't seem to wrap my thoughts around how to do it.

Basically I want to select every row that is distinct based on a single field, like:

Author | Book Name | Book Num
Bob | ThisBook | 1
George | ThatBook | 2
Fred | HisBook | 3
Bob | HerBook | 4

How would I select each author only once, but return the entire row for that unique result? Basically I'd want Bob, George, and Fred to all appear, but Bob to only appear once, not twice.

And this is assuming I can't change the table to be better structured, I don't have direct access to it. I realize how it SHOULD be set up, but unfortunately it is not.

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

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.

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