Jump to content

fenway

Staff Alumni
  • Posts

    16,168
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by fenway

  1. CONDITION is a reserved keyword...
  2. No, I don't think so. Why not: INSERT INTO table3 ( my_id, her_id) SELECT myid, ( SELECT `herid` FROM `table2` WHERE level='$level' LIMIT 1 ) FROM table1 WHERE myid = '$newid'
  3. Next time, don't double-post.
  4. Try this: ( select i.img_name , i.img_description , u.user_name from image as i inner join user at t on ( t.user_id = i.img_user ) ) union all ( select d.name , d.description , a.username from downloads as d inner join accounts as a on ( a.id = d.userid ) )
  5. I don't know what you're trying to do... but when you use union, you can't possibly get back the original column names from a unioned field that had two different names to begin with.
  6. there's no way that update can ever insert a record (unless there's a trigger).
  7. Hmmm... I just want to make sure that the indexes are working as expected. Drop the IN() too... ALL should switch to RANGE.
  8. Drop the != condition for a minute... it shouldn't be ALL.
  9. fenway

    MySQL Join?

    Everything is possible. Try: select t2.pin from table2 as t2 inner join table1 as t1 on ( t1.pin_number = t2.pin ) where t1.entered_pin = 1
  10. Way to persevere! Good job.
  11. Not easily... DBs are not really designed for this. Have you looked at Sphinx?
  12. I would have to disagree. Using prepared statements for sanitize data is really overkill -- there is a large overhead in using these, which really only pays off in certain circumstances. There's nothing "magical" about sanitizing sql queries... all you need to do is escape quotes, nothing more. I don't think this is shakey or messy, as long as you use a DB class that handles this for you.
  13. The first one can return nonsense, since you're using an aggregate function without a proper group by clause -- this has two effects: (1) you'll only get back one row since you're group by "all" and (2) the column values will be utter garbage. You may have to use a subquery.
  14. If you don't know, than neither do we... start debugging your script to identify the problematic section of code.
  15. Why all the extra semi-colons?
  16. Check mysql_error() after running the query... what mysql version?
  17. NO! It might work, but you've dropped the column list... BAD IDEA. The reason you had the problem was that "from" is a reserved keyword, so you needed to enclose it in backticks (`from`). However, I'd recommend changing the name of the column instead. And I hope you're still escaping those data!!!!
  18. Two things: 1) there doesn't appear to be any useful index for table1 or table2 2) the temp/filesort comes from the fact that you're sorting on a join-ed table.
  19. It's not tough at all.. a few joins ought to do the trick. What do you want to display at the edn?
  20. mysqlreport will give you some useful information... so will the slow query log.
  21. Assuming the column is auto-increment... better to leave the column out of the list entirely.
  22. Note that if the columnName does NOT match of the of the listed values, it will sort FIRST... so you may want to "reverse" it.
  23. You need to switch to left join for all the related tables... and be careful about getting back non-aggregated columns with group by.
  24. Actually, I didn't realize that you can use subqueries as well... try this: SELECT * FROM `events` WHERE `start_date` BETWEEN ( STR_TO_DATE(((PERIOD_ADD( EXTRACT(YEAR_MONTH FROM ADDDATE(SYSDATE(),INTERVAL -1 MONTH) ) , 1 ) *100) +1), '%Y%m%d' ) ) AND ( STR_TO_DATE(((PERIOD_ADD( EXTRACT(YEAR_MONTH FROM ADDDATE(SYSDATE(),INTERVAL +0 MONTH) ) , 1 ) *100) +1), '%Y%m%d' ) ) ORDER BY `start_date` ASC
  25. Yeah, guess so.... I thought 4.0 had support for those, but I guess not.
×
×
  • 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.