Jump to content

Kriek

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    jdkriek
  • MSN
    jdkriek@hotmail.com
  • Website URL
    http://jonkriek.com
  • ICQ
    132364102
  • Yahoo
    jdkriek

Profile Information

  • Gender
    Not Telling
  • Location
    Florida

Kriek's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. In MySQL use the SUBSTRING() function. SELECT * FROM aud_desc ORDER BY SUBSTRING(aud_code, 1, 1);
  2. Justnew, if you utilized either of my previous examples, the price column individually is non-existent. This is due to the fact that we have combined the values of the price and profit columns and then proceeded to alias that sum as total with the AS keyword. I do not recommend aliasing two columns with an original column name. To clarify why your previous method did not work is because the AS keyword is optional when aliasing a SELECT expression. So by not separating the pepper and price columns with a single coma you effectively aliased the pepper, price, and profit columns as price.
  3. Method no.1 SELECT tea, mango, pepper, price + profit AS total FROM products Method no.2 SELECT tea, mango, pepper, (price + profit) AS total FROM products
  4. Alien, no problem, and glad I could be of assistance to you.
  5. See -> ADOdb -> Making MySQL Efficient Tutorial
  6. Run the following query: REPAIR TABLE phpbb_topics_watch
  7. .. but you can still rewrite the query without a subquery. SELECT Intervenciones.* FROM Intervenciones,Respuestas WHERE Intervenciones.IntId=Respuestas.ResResIntId;
  8. More simplistic than phpMyadmin? No. phpMyAdmin v2.5.x is essentially point-and-click interfacing.
  9. Use the wildcard % characters. SELECT * FROM Persons WHERE vn LIKE \'%$vn%\';
  10. Right in this case use COUNT() rather than SUM(), however as long as you have an AUTO_INCREMENT field asterisks are NOT needed. Also note that COUNT(expr) returns a count of the number of non-NULL values in the rows retrieved by a SELECT statement, while COUNT(*) returns a count of the number of rows retrieved, whether or not they contain NULL values. Do not be tempted to use mysql_num_rows(), using COUNT(expr) or COUNT(*) is a lot faster. [php:1:3b0788305a]<?php $conn = mysql_connect(\'dbhost\', \'dbuser\', \'dbpass\') or die(mysql_error()); mysql_select_db(\'dbname\', $conn) or die(mysql_error()); $query = \"SELECT COUNT(ID) AS totalrecords FROM table\"; $result = mysql_query($query, $conn) or die(mysql_error()); $row = mysql_fetch_assoc($result) or die(mysql_error()); $totalrecords = $row[\'totalrecords\']; echo \'Total Records \' . $totalrecords; mysql_close($conn) or die(mysql_error()); ?>[/php:1:3b0788305a]
  11. See the SQL functions SUM() and/or COUNT() SELECT SUM(ID) AS totalrecords FROM table Then access totalrecords from the mysql_fetch_assoc() function [php:1:826a0f1673]<?php $conn = mysql_connect(\'dbhost\', \'dbuser\', \'dbpass\') or die(mysql_error()); mysql_select_db(\'dbname\', $conn) or die(mysql_error()); $query = \"SELECT SUM(ID) AS totalrecords FROM table\"; $result = mysql_query($query, $conn) or die(mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result) or die(mysql_error()); $totalrecords = $row[\'totalrecords\']; echo \'Total Records \' . $totalrecords; } mysql_close($conn) or die(mysql_error()); ?>[/php:1:826a0f1673]
  12. phpMyAdmin -> Database -> Export -> Hold control and select all tables. -> Check SQL, Structure, and Data.
  13. Yes absolutely, that IS what he wants; read his annotations.
  14. No, you are misunderstanding the purpose of the LIMIT clause; constructed as offset, row_count. This query is intended to start at row 25 and only pull one row. SELECT * FROM table WHERE level=\'0\' LIMIT 25,1; This query is intended to pulls rows 25, 50, 100 ect. SELECT * FROM table WHERE MOD(ID,25)=\'0\' AND level=\'0\';
  15. With my previous example, I thought it was painfully obvious. SELECT * FROM table WHERE MOD(ID,25)=\'0\' AND level=\'0\'; So you only want the 25th row, as in singular? SELECT * FROM table WHERE level=\'0\' LIMIT 25,1; Additionally if you only need the ID for each row, get rid of the asterisk; it is truly evil. SELECT ID FROM table WHERE level=\'0\' LIMIT 25,1;
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.