Jump to content

php_fish

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

php_fish's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I pull the stored query from the database then use it. At he moment I'm doing a preg_replace on the query but wondered if there is a better way to do it
  2. I'm storing mysql queries in a database. I want to store the $_GET key in my query so that when I pull the query from the db it replaces '$_GET['id']' with whatever the value happens to be, eg $sql = "SELECT * FROM users WHERE user_id = ".$_GET['id'] I serialize the data before it's entered into the db as the qury is part of an array of data. I just can't work out the proper format. It's fine when I don't have a dynamic variable inside the query. Any help will be much appreciated.
  3. Yes, that works perfectly. Once again you've helped me out. Thank you!
  4. I reversed the LEFT to a RIGHT join and it works fine on both platforms. Thanks for pointing me in the right direction. Still doesn't explain the different results earlier but hey I'm a happy chappy now woooooo weeeee
  5. I should also point out that my local system is windows xp and the host run on Linux. Not sure if that should make any difference but that and version difference is all I can think of
  6. SELECT content.idcontent, content.title, content.main_body, media_files.file_name,media_files.media_type,media_assign.idmedia_assign,media_files.id_media_files FROM (media_files LEFT JOIN media_assign ON media_files.id_media_files = media_assign.id_media_files AND media_files.media_type = 0) RIGHT JOIN content ON content.idcontent = media_assign.idcontent GROUP BY content.idcontent ORDER BY content.idcontent DESC;
  7. I'm running version 4.1.7 MySQL on my local machine, my hosting company is running version 4.1.22. I get different results when I run the same query. Is this to be expected? Were there some changes released with version 4.1.7 that causes this?
  8. I've tried; SELECT a.idimg FROM images a LEFT OUTER JOIN assignedimages b ON a.idimg = b.idimg WHERE b.idimg IS NULL AND assignedimages.idcontent != 1 again with no luck
  9. tried that, it doesn't give me want I want. I want all images except for those assigned to record 1 in he content table (for example). Since an image can be assigned to more than one content record that query still returns the images that record 1 has assigned to it because other content records have the same images assigned.
  10. I'm not getting very far, have spent several days trying out your suggestion but with no luck. Can anyone advice me on the syntax of such a query. Can it be done without the intervention of php?
  11. I have 3 tables; #######table content#### idcontent title copy ------------------------------------ 1 title1 text1 2 title2 text2 3 title3 text3 4 title4 text4 #######table images #### idimg file ------------------- 1 img1.jpg 2 img2.jpg 3 img3.jpg 4 img4.jpg ####### assigned images #### idassign idcontent idimg ------------------------------------------ 1 1 2 2 1 1 3 3 2 4 4 3 I'm trying to build a query that will give me all images that are not assigned to a specific content id. Because the same image can be assigned to any number of contentid's I'm finding it tricky. The sql I'm using at the moment is a simple select all images SELECT file, idimg FROM images I've tried various other queries involving joins and sub queries but I just can't work it out. MySQL is not my strongest skill Any help will be greatly appreciated
×
×
  • 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.