there must be a way of combining the following two queries. the documentation is limited when it comes to using more sophisticated techniques. i suppose they want me to buy a book on the subject.

i feel like i'm making the server do too much work by executing these queries separately. but let's face it, what do i know about mysql server optimization. is combining them really worthwhile?

SELECT date, REMOTE_ADDR FROM counter_track WHERE date = NOW() AND REMOTE_ADDR = 'some ip address'
if ( ! mysql_num_rows($result) ) { # this ip address hasn't been tracked today
$result = mysql_query ("INSERT INTO ".$tablePrefix."_counter_track (date, REMOTE_ADDR, HTTP_REFERER, QUERY_STRING) VALUES (NOW() , '".$pmAddr."', '".$pmHttp."', '".$pmQuery."')");
echo "<!-- tracked -->";
} else {
echo "<!-- previously tracked -->";