If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > compounding mySQL queries

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-03, 12:55
giskard giskard is offline
Registered User
 
Join Date: Oct 2003
Posts: 1
compounding mySQL queries

there must be a way of combining the following two queries. the mysql.com 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 -->";
}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On