Re: [nyphp-talk] SQL question

2007-07-24 Thread Rob Marscher
OK... I actually looked in the manual this time to get some clarification - http://dev.mysql.com/doc/refman/5.0/en/join.html: "INNER JOIN and , (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, ea

Re: [nyphp-talk] SQL question

2007-07-24 Thread Adrian Noland
On 7/23/07, Rob Marscher <[EMAIL PROTECTED]> wrote: If you did an INNER JOIN: SELECT u.id, s.id FROM user u INNER JOIN session s ON u.id = s.user_id WHERE u.id = 5 ... We had a discussion last year on NYPHP-MySQL about INNER JOIN versus commas (cartesian join) -- you so often see it with

Re: [nyphp-talk] SQL question

2007-07-23 Thread Michael Southwell
At 11:08 PM 7/23/2007, you wrote: Going back to that original query, you can write it like this: SELECT cupssbmain.StoryboardID AS sbid FROM cupsmodules, cupslessons, cupspages, cupssbmain WHERE cupsmodules.CourseID = 23 AND cupslessons.ModuleID = cupsmodules.ModuleID AND cupspages.LessonID

Re: [nyphp-talk] SQL question

2007-07-23 Thread Rob Marscher
On Jul 23, 2007, at 3:45 PM, David Krings wrote: So, I guess now that I got this settled I better learn what a left join is in case someone asks me to explain my code. :) LEFT JOIN actually is short for LEFT OUTER JOIN. OUTER JOIN means that it doesn't require finding a match... if it doesn

Re: [nyphp-talk] SQL question

2007-07-23 Thread Mark Armendariz
David Krings wrote: Rob Marscher wrote: SELECT s.StoryboardID FROM cupscourses c LEFT JOIN cupsmodules m ON m.CourseID = c.CourseID LEFT JOIN cupslessons l ON l.ModuleID = m.ModuleID LEFT JOIN cupspages p ON p.LessonID = l.LessonID LEFT JOIN cupsstoryboards s ON s.PageID = p.PageID W

Re: [nyphp-talk] SQL question

2007-07-23 Thread David Krings
Rob Marscher wrote: SELECT s.StoryboardID FROM cupscourses c LEFT JOIN cupsmodules m ON m.CourseID = c.CourseID LEFT JOIN cupslessons l ON l.ModuleID = m.ModuleID LEFT JOIN cupspages p ON p.LessonID = l.LessonID LEFT JOIN cupsstoryboards s ON s.PageID = p.PageID WHERE c.CourseID = 23

Re: [nyphp-talk] SQL question

2007-07-23 Thread Rob Marscher
Hey David, I just got around to checking the list... would have replied on the NYPHP-Mysql thread... but it seems like it's back here now. Are you using MySQL? If not, the syntax could be slightly different but should be mostly the same. Data Hierarchy: Courses Modules Lesso

Re: [nyphp-talk] SQL question

2007-07-23 Thread David Krings
Mark Armendariz wrote: I tried replying on the mysql list the other day but never got a bounce and it never went through. Here's what I posted.. Thanks for reposting. I'm taking a guess here and please forgive me if I'm incorrect in my assumptions, but it looks like you're going to want to l

Re: [nyphp-talk] SQL question

2007-07-23 Thread Mark Armendariz
David Krings wrote: cupssbmain: StoryboardID, PageID, LessonID, ModuleID, CourseID cupspages: PageID, LessonID, ModuleID, CourseID, Page_Position cupslessons: LessonID, ModuleID, CourseID, Lesson_Position cupsmodules: ModuleID, CourseID, Module_Position Hi David, I tried replying on the mysql

Re: [nyphp-talk] SQL question

2007-07-23 Thread David Krings
Steve Manes wrote: Without seeing the actual SQL query it's impossible to guess where the problem is. In general though, cartesian joins are the result of incomplete join conditionals and, sometimes, overly-complex WHERE clauses in cases where a left join or sub-select would be more reliable.

Re: [nyphp-talk] SQL question

2007-07-23 Thread PaulCheung
P Talk" Sent: Monday, July 23, 2007 4:55 AM Subject: Re: [nyphp-talk] SQL question David Krings wrote: I'm getting back the rows that I want, but not in the correct order and only by using DISTINCT, which I once was told is a nono and not needed if I'd just do it right. M

Re: [nyphp-talk] SQL question

2007-07-22 Thread Steve Manes
David Krings wrote: I'm getting back the rows that I want, but not in the correct order and only by using DISTINCT, which I once was told is a nono and not needed if I'd just do it right. My attempt to output the columns that contain the values the reocrds are to get sorted on ends up in being

Re: [nyphp-talk] SQL question

2007-07-21 Thread David Krings
pyurt wrote: David I have experienced similar problems in the past. What are you getting back? Which version PHP? I'm getting back the rows that I want, but not in the correct order and only by using DISTINCT, which I once was told is a nono and not needed if I'd just do it right. My attem

RE: [nyphp-talk] SQL question

2007-07-20 Thread pyurt
David I have experienced similar problems in the past. What are you getting back? Which version PHP? Paul The most accurate credible, & timely website directory on the web: mastermoz.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Krings Se

Re: [nyphp-talk] SQL question

2007-07-20 Thread David Krings
Aaron Fischer wrote: Here? http://lists.nyphp.org/mailman/listinfo/mysql That was almost too easy...thanks! David ___ New York PHP Community Talk Mailing List http://lists.nyphp.org/mailman/listinfo/talk NYPHPCon 2006 Presentations Online http://ww

Re: [nyphp-talk] SQL question

2007-07-20 Thread Aaron Fischer
Here? http://lists.nyphp.org/mailman/listinfo/mysql Hi! What is the best place to bug someone about a pure SQL question? I need to join multiple tables and no matter what I do, it just doesn't get me the wanted results. So, any pointers are welcome. David ___