How Expensive Are Calls To Mysql?

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

How Expensive Are Calls To Mysql?

fsoftball
Hi,

I would like to sharea design I am currently using and have you all tell me if it is an optimal way of doing things.

First, here is a table (named schedule) in my MySQL database:

game_ID Result
1 W
2 L
3 W
4 T

In my PHP code I want to get the number of wins (W), losses (L), and ties (T). Here is how I did it:

CODE

$wins_sql = "SELECT * FROM schedule WHERE result = 'W'";
$loss_sql = "SELECT * FROM schedule WHERE result ='L'";
$tie_sql = "SELECT * FROM schedule WHERE result ='T'";
$num_loss = mysql_num_rows(mysql_query($loss_sql, $conn));
$num_wins = mysql_num_rows(mysql_query($wins_sql, $conn));
$num_tie = mysql_num_rows(mysql_query($tie_sql, $conn));
echo "Overall Record: $num_wins - $num_loss - $num_tie\n";


Are using three different sql statements the best way to do this? If not, can you please provide an example of what would be better? Thanks!

 

 

 


Reply

Tyssen
I think you want to do something using GROUP BY:

CODE
select result, count(*) AS Number
from table
GROUP BY result
ORDER BY Number;

You don't need Number as a field in your table - you're specifying another value to use in your SQL with the AS command.

Reply

fsoftball
Yeah!!! That works from a MySQL view point, but I'm not suer what to do with the returned resutlts from a PHP standpoint.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : expensive, calls, mysql

  1. Mysql Hacks
    (1)
  2. Creating A Php Login System Using Mysql
    I need help in creating a login system, what I want is a login system (10)
    Hey everyone! I am helping someone make a login system using MySQL databases and a PHP login
    form. I have a fair bit of experiance in HTML and some javascript too. I have virtually no
    experiance in MySQL or PHP. Anybody know of any good PHP login systems that allow you to creat a
    personalised page for each user and when they login the system transfers the user to their page.
    Another thing that the system MUST have is a way of stopping unwanted users entering someones page.
    CODE For example lets say I register and my UN is jesse123 and my personalised pages a....
  3. Mysql Database Not Working
    (3)
    well i'm getting an error message(a databass connection warning) for all of the parts of my site
    that connects to a mysql database i check my database users pertmissions and i try to do the repair
    database thing and it's still not woeking. am i the only person having this or is it an overall
    trap17 issue and how do i fix it.....
  4. The Only Reason I Choose Ms Sql Server Rather Than Mysql
    (0)
    The only reason i choose ms sql server rather than mysql is, MS SQL has more security
    features!! MySQL is lacking a lot in my opinions - Lack in wide char, like nvarchar, I
    developed some application to support chinese letter, and dont know how to build one in mysql - Lack
    in t-sql syntax, like query in query is not fully supported - Does not have today SQL features like
    BI support (today really required) And compare MS SQL to MySQL, the only reason why mysql is
    favourable is - it is free! Dont u guys agree?....
  5. Need Advice On Setting Up Mysql Database.
    I have a huge amount of daily data updates to be inserted. (4)
    First of all, to get the idea of what I am trying to achieve here, please have a look at my
    idea thread, entitled Idea For Using A Cron Job To Grab Daily Travian Map.sql Updates . This gives
    a prelude to the project, what it is for, what it is supposed to do, etc. Now, what I need is
    specific advice on setting up the mySQL database(s) to implement this idea. There is a useful FAQ
    file for how to make use of the map.sql data located on the help.travian.com website, which also
    gives an example of the CREATE TABLE instruction that matches the data in the map.sql fi....
  6. Mysql Db Is Down Getting Following Error
    (2)
    My Mysql is Down can I get some help please? Appreciate it. Patrick Domain: patrickcurl.com Error:
    phpMyAdmin - Error #2002 - The server is not responding (or the local MySQL server's socket is
    not correctly configured)....
  7. Expensive Car ?
    (3)
    what is the name of the most expensive car of the world ? is that rolws Royes? and what is the most
    power full truck of the world ?....
  8. It Went Well For A While
    MySQL problem back in all its glory. (5)
    Some time ago I had a stubborn problem when trying to access one of the interactive pages on my
    website and getting the following error: QUOTE Warning: fopen() : open_basedir restriction in
    effect. File(include/errors.xml) is not within the allowed path(s):
    (/home/mrdee:/usr/lib/php:/usr/local/lib/php:/tmp) in
    /home/mrdee/public_html/admin/include/commonfunctions.php on line 682 Warning:
    fopen(include/errors.xml) : failed to open stream: Operation not permitted in
    /home/mrdee/public_html/admin/include/commonfunctions.php on line 682 Cannot open XML data file:
    incl....
  9. How Do I Find My Mysql Password? [resolved]
    Cannot access my MySQL (5)
    After all the recent problems, my account has been restored. I have setup my parked domain agin, and
    that works fine. However, I can no longer access my MySQL databases (I can from PHPMyAdmin, but
    that's all). I had to create a new user for my databases, and created the user with exactly the
    same username and password I had before, but some of my web pages do not let me access the pages I
    have associated with my databases. Where could i find out what my DB password is? (Although I am as
    good as sure I am using the right one). I have tried my old password, the new c....
  10. Please Explain Me Mysql
    How do i insert information into this config: (4)
    Hi, I wanted to try just to test how can i connect my website to another mysql server, but i have no
    idea how to insert the other mysql information such as port and host etc.... so here is the config
    file please give me an example CODE <?php // mySQL information $server =
    'FRESHSQL.COM:3306';                   // MySql server $username =
    'vasilevich';                      // MySql Username $password =
    '*******';                         // MySql Password $database =
    'vasilevich';                  // MySql Da....
  11. Remote Access Mysql
    (8)
    Is it possible to directly access my local database from my website? For example, if somebody
    submits info on my website, the info they submitted would be transferred to my local database
    directly. Is that possible? And if so, how do I set that up? The reason I don't want to upload
    my database to my subdomain is because it would be difficult to keep the website database and my
    local database in sync . . . or is there a way to do that? Thanks for any replies.....
  12. Create Table - Mysql Code - Help
    (1)
    I need your feedback about setting the database issues. Please, review them and correct some entries
    in the code if they got some mistakes. This is the code itself: SQL CREATE TABLE
    `news` ( `id` int(250) NOT NULL auto_increment, `title` varchar(255)
    NOT NULL default '', `text` text NOT NULL, `author` varchar(255) NOT
    NULL default '', `valid` varchar(255) NOT NULL default '',
    `date` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE = ....
  13. Html Form!
    Using MySQL?! (4)
    Hey, I need your help again! I need some good working tutorial how I can update my SQL through
    HTML form. I did use some tutorials online found with the help of google; but they do not work
    properly; I mean there are still small mistakes. I need to have a good tutorial to follow. It
    should be based on security and more things. It has to be done in proper way.......
  14. Taking Phone Calls At Work
    (2)
    A potential client's first contact with the company is usually through the phone, so it is
    important that you make it a pleasant experience for him. Important phone etiquettes to bear in
    mind: When answering the phone, identify your company, department and state your name immediately
    name e.g. This is from the of . When talking to customers, call them by name. By repeating the
    name, you are more likely to remember it the next time. It also sounds more personalized and
    friendly. Know how you sound like to others. You can find this out by recording your voice.....
  15. Mysql, Php, Apache Downloads And Setup Was A Nightmare
    Mysql, PHP, Apache (10)
    Mysql, PHP, Apache downloads were easy enough. Then came the setup process. This seemed to be an
    endless mess of going back and forth trying to get the programs to work together properly. Finaly I
    got them working after about 48 hours. There are great tutorials on the setup process, but only one
    or two actualy were easy enough for me to understand. I would like to see if I was the only one who
    had issues with this setup. Are there easier ways to setup the three?....
  16. Mysql-essential-5.0.51 Installion Problem
    please help me.(urgent) (2)
    Dear friend, please help me. Iam working on php project (matchmaking site). I have downloaded mysql
    essensial 5.0.51. When i was installing mysql 5.0.51, i got following error - Error 1901: Error
    attempting to read from the source installation database:
    c:\windows\installer\527ec6.msi What is solution of this problem ? Iam using
    windows xp professional version 2002 (service pack 2). Please post your reply. Iam waiting for your
    answer. ....
  17. Database With Mysql++
    getting mySQL++ to work with trap17 (7)
    Hi, I'm trying to build an online game and figured the easiest way to do the server list would
    be to make a mySQL database for it; however, I use the con() command on the IP i get from pinging my
    website and I always get an abnormal program termination; however, it will work with the mySQL on my
    own machine. The code is below: CODE #include <iostream> #include <iomanip>
    #include <mysql++> #include "pass.h"//holds my password (i program at
    school) int main(void) {     Connection con("t3jem3_test","....
  18. Ie 7 Issue With Ajax
    Some ajax calls dont seem to work (2)
    function reload_char() { race_id = Ext.get('race').dom.value; gender =
    Ext.get('race_gender').dom.value; face = Ext.get('race_face').dom.value; hair_id =
    Ext.get('race_hair').dom.value; // race race_letter =
    Array('H','E','T','M','G'); race = race_letter ; /*
    //gender if(race == 'G' || race == 'M') { gender = ''; } //hair
    if(hair_id == 1) { hair = 'a'; } else { hair = 'b'; } image =
    '80px-'+race+gender+face+hair+&....
  19. Mysql Won't Update
    (4)
    Ok, so I'm making some arcade administration software so I don't have to add games the hard
    way, well anyway, one of the features I have is that on the homepage is a featured author and as
    such I just have it so it updates one line in the mySQL. Well, the page with the form passes on the
    varibles fine and the updating page recieves them because I echoed everything, then I build the
    query and I even echo the query and it comes out exactly how I want it to, but for some reason, the
    database itself won't update even though all the varibles are there. Here's....
  20. Qupis : Free Hosting With Php, Mysql, Cpanel. (one Line Text Ad At Bottom)
    a member of Xisto (41)
    Hello Members, We are proud to introduce a new member to Xisto group of sites.
    Qupis : Free Web Hosting 150 MB space, 5000 MB Bandwidth, php,
    mysql, CPanel (Latest). Emails, FTP, Addon domains, Parked Domains etc.
    http://www.Qupis.com
    Feel free to add your reviews and comments about it. -Trap17
    Management ....
  21. Make Calls From The Internet?
    How can I make calls from the internet? (8)
    Could you please let me know..How can I make calls from the internet? I know some of the tools
    like skype with which we can call any landline number within a country..!! is there any tool
    with which I can make calls to mobiles and to any country? Please reply to me.. Thanks in
    advance.. Prakash ....
  22. Is It Possible To Access The Mysql Remotely?
    (10)
    I like to experiment with a lot of things and I was thinking of making a sort of instant messenger
    in Python, but I want to let people have actual accounts so I need to be able to access the mySQL
    remotely. If that's not possible, are we allowed to run Python scripts on the server?....
  23. Check Referrer To Prevent Linking Yours From Other Sites
    Check referrer with Php and Mysql (8)
    Check Referrer Using Php To Prevent People Linking To Your Downloads From Other Sites Ever
    find that found some people are listing items, images and tuts and linking directly to the download
    url (those that are like my photoshop tutorial.php?id=0), which is a .php to count the number of
    downloads. To prevent this, you can add a piece of code to the download pages that checks which page
    referred them to the download page: if it's my domain, it downloads the file normally, if
    it's not, it will redirect to my home page instead. Important : Not all browser....
  24. Quick Question
    Is there a limit on the size of the MySQL database? (10)
    Question's in the title!....
  25. Subquery In Mysql
    (5)
    Is there anyway to make subqueries work in MySQL? I'm pretty certain someone out there knows
    how. /smile.gif' border='0' style='vertical-align:middle' alt='smile.gif' /> Can anyone help?
    CODE Select * from ITEMS where ID="Select Max(ID) from ORDERS"; This works
    for MSAccess and SQL Server but why not in MySQL? I'll be writing some reports and I've
    shifted database from MSAccess to MySQL. Help! Thanks.....
  26. Mysql Database Size
    related to the free database space (7)
    hi all! this is my first post /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> and i have a doubt, how much mysql space i am allowed to use... i mean how
    much is available for my free account....
  27. Import From Excel File Into Mysql Database
    (11)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  28. Increment A Mysql Column
    how to increment a MySQL column one unit (7)
    Hi, I have a column in a MySQL table which contains a counter of the views of the object described
    by this table. I would like to increment this value by one everytime the object is viewed. Obviously
    came into my mind the possibility of retrieving the value of this field, store it in a variable
    increment this value by one and perform an UPDATE query again with this new value. My question is if
    there is a MySQL option to update the field with its actual value plus an unit increment. I hope you
    understand the issue.....
  29. Complete Login System
    With PHP + MYSQL (57)
    Its an complete login sistem made and tested by me and I think itwill be very usefull for people who
    are tryn to learn PHP. First, let's make register.php: CODE <?
    include("conn.php"); // create a file with all the database connections
    if($do_register){ // if the submit button were clicked if((!$name)
    || (!$email) || (!$age) || (!$login) ||
    (!$password) || (!$password2)){ print "You can't let
    any fields in blank....
  30. Mysql Database Setup : Setting Up Mysql Database
    Guide to use MySQL database in your site (6)
    A SMALL INTRODUCTION TO DATABASE ============================= I have seen that many members have
    problems with Database. Here is a small INFO which should give you the IDEA. mySQL is a DATABASE
    server. You can access it using the link in Cpanel. Cpanel can be accessed by
    "www.YOUR-SITE.com/Cpanel" There you have 4 Main Options :- 1> CREATE A DATABASE 2> CREATE A USER
    3> ADD USER TO DATABASE 4> PHPMYADMIN CREATE : IT ALLOWS YOU TO CREATE A DATABASE CREATE USER
    : IT ALLOWS YOU TO CREATE A USER. USING THIS, YOU CAN ACCESS THE DATABASE. A DATABASE CANNOT BE....

    1. Looking for expensive, calls, mysql

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for expensive, calls, mysql

*MORE FROM TRAP17.COM*
Similar
Mysql Hacks
Creating A Php Login System Using Mysql - I need help in creating a login system, what I want is a login system
Mysql Database Not Working
The Only Reason I Choose Ms Sql Server Rather Than Mysql
Need Advice On Setting Up Mysql Database. - I have a huge amount of daily data updates to be inserted.
Mysql Db Is Down Getting Following Error
Expensive Car ?
It Went Well For A While - MySQL problem back in all its glory.
How Do I Find My Mysql Password? [resolved] - Cannot access my MySQL
Please Explain Me Mysql - How do i insert information into this config:
Remote Access Mysql
Create Table - Mysql Code - Help
Html Form! - Using MySQL?!
Taking Phone Calls At Work
Mysql, Php, Apache Downloads And Setup Was A Nightmare - Mysql, PHP, Apache
Mysql-essential-5.0.51 Installion Problem - please help me.(urgent)
Database With Mysql++ - getting mySQL++ to work with trap17
Ie 7 Issue With Ajax - Some ajax calls dont seem to work
Mysql Won't Update
Qupis : Free Hosting With Php, Mysql, Cpanel. (one Line Text Ad At Bottom) - a member of Xisto
Make Calls From The Internet? - How can I make calls from the internet?
Is It Possible To Access The Mysql Remotely?
Check Referrer To Prevent Linking Yours From Other Sites - Check referrer with Php and Mysql
Quick Question - Is there a limit on the size of the MySQL database?
Subquery In Mysql
Mysql Database Size - related to the free database space
Import From Excel File Into Mysql Database
Increment A Mysql Column - how to increment a MySQL column one unit
Complete Login System - With PHP + MYSQL
Mysql Database Setup : Setting Up Mysql Database - Guide to use MySQL database in your site
advertisement



How Expensive Are Calls To Mysql?



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE