-
Posts
422 -
Joined
-
Last visited
-
Days Won
1
Everything posted by awjudd
-
Insert only date where month is not previous month
awjudd replied to newphpcoder's topic in MySQL Help
I believe I had it flipped (because of your query). if($ETD_month==$date_now) { $sql= '...'; // Execute query. mysql_query($sql); } -
Insert only date where month is not previous month
awjudd replied to newphpcoder's topic in MySQL Help
In you PHP code, before you run the INSERT statement, do a quick if statement to check $ETD_month != $date_now. if($ETD_month==$date_now) { // Insert } ~awjudd -
Insert only date where month is not previous month
awjudd replied to newphpcoder's topic in MySQL Help
Why aren't you just kicking it out on the PHP side of things? Why should the query be preventing this insert? The INSERT INTO statement when used with VALUES shouldn't accept a WHERE clause because it doesn't make sense at all. ~awjudd -
You are missing a , between the two values that you are updating. $sql_rating = "UPDATE movie SET rating='$sum_rating', num_votes='$sum_num_votes' WHERE title='$title'"; ~awjudd
-
As will I ... I already started using it on Google Plus ~awjudd
-
Is the photo column a BLOB? Is your table properly indexed? Run an EXPLAIN on the query to get more information on the actual query. ~awjudd
-
You are logging slow queries to "/var/lib/mysql/vps-slow.log" ... so show us what is in that file. ~awjudd
-
Because that is an invalid query. It should be IS NOT NULL. CREATE VIEW loDensity AS SELECT Name, SurfaceArea, Population, Population / SurfaceArea AS popDensity, LifeExpectancy FROM country WHERE LifeExpectancy IS NOT NULL With views, when in doubt, just try to copy and past the SQL and see the error message. ~awjudd
-
Inserting using the set-based notation doesn't need the () around the values. The following should work: safe_query("INSERT INTO ".PREFIX."cup_matches ($type, $type_opp, matchno, clan1, clan2, comment, 1on1) SELECT a.$type, a.$type_opp, a.matchno, a.clan1, b.clan2, a.comment, a.1on1 FROM ".PREFIX."cup_matches a, ".PREFIX."cup_matches b WHERE a.clan2 != b.clan2 AND a.matchno = '$ID' AND b.matchno = '$ID' AND a.$type='h' AND b.$type='h'"); ~awjudd
-
You can use MySQL's REPLACE function http://dev.mysql.com/doc/refman/5.0/en/replace.html Either do it in a SELECT statement (non-permanent) or an UPDATE statement (changing the actual values in the table). ~awjudd
-
If you aren't trying to join the table together, then add semi-colons between each of your queries and you can run more than 1. ~awjudd
-
Unless you have a key which you can order by, there is no way of doing what you are wanting. The only way would be to add a "DisplayOrder" column and then fill that in with the corresponding order and then when selecting out of your table, you would add "ORDER BY DisplayOrder" to your query. ~awjudd
-
You will need to prefix your tables in the WHERE and ORDER BY clauses. That said, you are currently doing a CROSS JOIN between these two tables which I don't think that is what you want. As Maq said, you probably want to do a JOIN. ~awjudd
-
@KingPhilip - You said what was said in the Gold Room stayed in the Gold Room ...
-
Stupid question ... but why would anyone pay to talk to you?
-
I don't mind using Mantis (http://www.mantisbt.org/) for logging bugs and stuff ...
-
As AyKay47 said, your query is doing the exact same as just a straight SELECT on that table. However that said, to answer your question it is because you have a subquery so you need to alias that table in order for SQL to know what to refer to it as: SELECT cadetId, lastName, firstName FROM ( SELECT tblcadets.pkCadetId AS cadetId, tblcadets.lastName AS lastName, tblcadets.firstName AS firstName FROM tblcadets AS tblcadets ) AS a
-
If that is all you are doing ... why don't you just do the math in the database? SELECT (SUM(value_one) - SUM(value_two)) AS totalDifference FROM table
-
It means your query failed. Try adding or die(mysql_error()) to your query line ... $query = mysql_query("SELECT ´article_id´ , ´article_title´ , ´article_likes´ FROM ´articles´ ") OR die(mysql_error()) ;
-
SELECT DISTINCT r.id, r.title AS 'Recipe Title' , r.summary AS 'Recipe Summary', r.image , r.status AS 'Recipe Status', c.id, c.title ,c.summary, c.body, c.status,c.createdate,c.createuser,c.customerid,r.createdate, `firstname` , `lastname` FROM `recipies` AS r JOIN `customer` AS cu ON r.customerid = cu.id JOIN `comments`AS c ON cu.id = c.customerid WHERE r.status =1 LIMIT 0 , 30
-
Please Note: it is extremely helpful if you provide the actual error you are getting. ~awjudd
-
We recently moved up from igloos into huts. I hear there is this thing called the internet in the outside world, they haven't installed it on any of our servers up in Canada yet. ~awjudd
-
after a little help in moving data from one table to another.
awjudd replied to jasonc's topic in MySQL Help
As Muddy_Funster said, you use joins. Step 1 - write a SELECT query that will get the data how you need it (use joins as needed) Step 2 - use the query from Step 1 and put it into the INSERT Step 3 - sit back watch as the table gets filled -
after a little help in moving data from one table to another.
awjudd replied to jasonc's topic in MySQL Help
By using the set based insert. Write your SELECT statement from your first table to get the data like you need it in the destination table (where you are copying to) and then with that SELECT use it as you INSERT. INSERT INTO newTable ( f1, f2, f3 ) SELECT f1, f2, f3 FROM links -
Since it returns a boolean no matter what, you don't even need the if statement. return $row->cash > $finalcash && $row->core1 > $finalcore1 && $row->core2 > $finalcore2 && $row->core3 > $finalcore3 && $row->core4 > $finalcore4;