close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Count and Where in the same clause

Thread began 4/28/2014 9:53 am by anonymous | Last modified 4/28/2014 11:28 am by anonymous | 1677 views | 10 replies |

anonymous

Count and Where in the same clause

Im not sure how i can make this query work but basically I have:

SELECT COUNT (*) FROM student WHERE vivadue < CURDATE()

So i want to count the number of rows in the tables where the date in vivadate is less than todays date.

Sign in to reply to this post

Jason ByrnesWebAssist

try this:

SELECT COUNT (*) FROM student WHERE DATE(vivadue) < CURDATE()

Sign in to reply to this post

anonymous

no, im still getting the following error:

Error in query: SELECT * FROM project. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '*) FROM student WHERE DATE(vivadue) < CURDATE()' at line 1

Sign in to reply to this post

Jason ByrnesWebAssist

what is the full SQL for the recordset?

Sign in to reply to this post

anonymous

// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$sqlviva = "SELECT COUNT (*) FROM student WHERE DATE(vivadue) < CURDATE()";
// execute query
$resultviva = mysql_query($sqlviva) or die ("Error in query: $query. ".mysql_error());

Sign in to reply to this post

Jason ByrnesWebAssist

yeah, thats why the error doesnt make sense, you are showing a diferant query in the error.


try using a column name in the count function instead of *

SELECT COUNT (vivadue)

Sign in to reply to this post

anonymous

yea that confused me too!

ive changed that and the error is now :

Vivas Outstanding:Resource id #28

its the only query on that page so i have no idea where its picking project up from

Sign in to reply to this post

Jason ByrnesWebAssist

I'll need to troubleshoot directly, see the private message section.

Sign in to reply to this post

anonymous

The details are sent :)

Sign in to reply to this post

Jason ByrnesWebAssist

you have to use fetch row to return the results of the query:

$resultviva = mysql_fetch_row($resultviva);

and in the echo, specify which index to write:
<?php echo $resultviva[0] ?>

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...