Hi
i m trying to count all for example vans who has record as Van1,Van2 ETC...
physically in the database i have more than 200 Van1 ..but with select count gives me only 6..

SELECT COUNT(*) FROM route WHERE
van='Van1'
the rsult only 6 for others 0 and so

any help please

Recommended Answers

All 4 Replies

That query seems to be saying you only have 6 rows in the database with a value of 'van1'. I would have to say it is correct as the query is pretty straight forward. Have a close look at your data and see whats going on.
Is lower case an issue e.g. van vs Van?
There is no other data in the van column, trailing spaces, etc? You could test that with a LIKE against '%Van1%'

Hi
thanks for your answer really i have more than 700 Van1 and all written the same..but i get only 6 when i query them..

Is your database set to use case sensitive strings? Try

SELECT COUNT(*) FROM route WHERE van = 'van1'
SELECT COUNT(*) FROM route WHERE van = 'Van1'

and see how many records are returned.

hI
Thank you for your help i did this and it is working
SELECT COUNT(*) AS num FROM route WHERE SUBSTR(van,4,1)='1'; or 2 or 3 ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.