Jump to content

Difficult MYSQL query

Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Difficult MYSQL query Rate Topic: -----

#1 User is offline   haku 

  • 日本語 Ninja
  • Group: Members
  • Posts: 652
  • Joined: 21-September 07
  • Gender:Male
  • Location:Yokohama, Japan

Posted 28 January 2008 - 11:05 AM

I have two tables in a database:

Table 1 - files:

column 1 - ID
column 2 - deleted



Table 2 - seminar_files

column 1- seminar_id
column 2 - file_id



ID from table 1 and file_id from table 2 are the column that bridges these together. So for example, I may have a file with an ID of "hakurocks" in table 1, and that same 'hakurocks' may appear in table 2. It may appear zero times, one time or many times, but will have a different seminar_id for each time it appears.

I want to select all the IDs from from table 1 that aren't in table 2 when seminar_id is equal to 18 (for example). On top of this, I only want to select the files from table one where deleted is set to zero.

Anybody got an idea on how to put together this mysql query? I've tried a bunch of different ways, and I either end up with ALL the files from table one, or none!
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
0

#2 User is offline   Catalyst 

  • Codesmith
  • Group: Administrators
  • Posts: 1,049
  • Joined: 04-April 06
  • Gender:Male
  • Location:San Diego

Posted 28 January 2008 - 04:31 PM

Can you send me a dump of those tables so I can test my query before posting it? You can attach it to a PM if you want.
0

#3 User is offline   haku 

  • 日本語 Ninja
  • Group: Members
  • Posts: 652
  • Joined: 21-September 07
  • Gender:Male
  • Location:Yokohama, Japan

Posted 28 January 2008 - 06:43 PM

Heh, are you asking me to take a dump and send it to you? :)

I think some guy gave me an answer on another forum. I'll try it out and if it doesn't work I'll do that. Thanks though, I really do appreciate the willingness to help!
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
0

#4 User is offline   Caroll 

  • W.R. Private
  • Group: Members
  • Posts: 9
  • Joined: 01-December 08

Posted 01 February 2009 - 05:01 AM

select from table
table should not be between brackets.
if your table name is a variable then it should be '$ticket' instead of 'ticket', but i dont think its the case so just remove the brackets surrounding your table name.
hope this helps
Buy SSL certificates today and secure your website.
0

#5 User is offline   haku 

  • 日本語 Ninja
  • Group: Members
  • Posts: 652
  • Joined: 21-September 07
  • Gender:Male
  • Location:Yokohama, Japan

Posted 02 February 2009 - 12:43 AM

Are you reading a different thread than me?
<a href="http://www.jaypan.com" target="_blank">Jaypan</a>
<a href="http://www.dudes-japan.com" target="_blank">Dudes Japan</a>
0

#6 User is offline   EncoderDecoder 

  • W.R. Sergeant
  • Group: Members
  • Posts: 260
  • Joined: 01-March 11
  • Gender:Female
  • Location:Philippines

Posted 15 April 2011 - 08:47 AM

is this already solved..?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users