The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> SQL uncontrollable
edson1314
post Nov 15 2010, 10:36 PM
Post #1





Group: Members
Posts: 4
Joined: 15-November 10
Member No.: 13,153



I already expressed in a previous post (if possible delete) and I did so very awkward.
That is a better presentation of my problem:
I have 3 tables:
- Members (site members)
IPB Image


- Categories (categories of members: developer, designer, etc. ..)
IPB Image


- Skills (the skills of members in each category (php / mysql developer in 2D and 3D design, etc ...)


IPB Image

My goal is: (in the context of a search by jurisdiction, category etc ...)
Display for each member who responds to his nickname search criteria, skills, date of postulation etc. ...
The problem occurs at this time of reflection, I have attached the 3 tables in my SQL but the script does not do what I want!


Code: SQL
CODE
SELECT co.competence, co.type, co.time, co.note, co.id, ca.available ace available, ca.refs, m.pseudo, ca.id AS CategoryID,
ca.Class, DATE_FORMAT(datepostulation, "% D /% m /% Y") AS date, m.Class AS droitsmembre, m.id AS idmembre
FROM Categories AS ca LEFT JOIN Member AS m ON m.id=ca.idmembre
LEFT JOIN skills AS co ON co.type="Spe" AND co.CategoryID=ca.id WHERE m.valid=1 AND ca.state=1 AND ca.Class="Developer"






The results of this query looks like this:
Image utilisateur
Yet this does not suit me since the application displays one line per jurisdiction and not by individual. There's there is an inconsistency in the statement?

Thank you in advance!
T'ry.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
wgabrie
post Nov 26 2010, 01:13 PM
Post #2


Advanced Member
****

Group: Members
Posts: 148
Joined: 11-July 10
Member No.: 12,279



Let's see, I've not used SQL before, but I want to try looking it up.

So, You've used:
1. SELECT. I think you selected more entries than you defined using "AS". Could this perhaps be a problem?
2. AS - which is an: Alias.
3. JOIN specifically a LEFT JOIN
4. WHERE

From your description perhaps you are pulling the database tables in the wrong order. Or perhaps you need to focus on the "individuals" table first then join the other tables to it.

I'm not sure where you're going wrong.
CODE
SELECT
        co.competence,
        co.type,
        co.time,
        co.note,
        co.id,
        ca.available ace available,
        ca.refs,
         m.pseudo,
        ca.id
AS
        CategoryID,
        ca.Class,
        DATE_FORMAT(datepostulation, "% D /% m /% Y") AS date,
        m.Class AS droitsmembre,
        m.id AS idmembre

FROM Categories AS ca

        LEFT JOIN Member AS m
         ON m.id=ca.idmembre

        LEFT JOIN skills AS co
         ON co.type="Spe"
        AND co.CategoryID=ca.id

WHERE
     m.valid=1
AND ca.state=1
AND ca.Class="Developer"


I wish I could be helpful and remember the link where I read about sorting SQL statements, about a week ago, but I can't remember it or find it on W3schools.com right now. The closest I could find is ORDER BY, but that isn't it.

This post has been edited by wgabrie: Nov 26 2010, 01:41 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 27th April 2024 - 11:58 PM