0

I have a table with the following structure:

id | user_id | job | type

The scenario is as following:

"A person in a company is offering his skills, another person is looking for skills. They can fill in their offerings and searches. After filling this in, they need to see the matches between what they are looking for and others are offering."

  • So "job" is a string, f.e. "creating backup","repairing bike"
  • So "type" is a string, f.e. "searching", "offering"

Is it possible to get these matches with one query?

** edit **

id | user_id | job           | type
---|---------|---------------|----------
1  | 1       | Create backup | searching
2  | 1       | Format osx    | searching
3  | 2       | Create backup | offering
4  | 1       | Program PHP   | offering

I want to do a query SELECT * FROM table WHERE user_id = 1 AND type = 'offering' ... with a result that provides me an array of all the other users that are offering this. So that the user has a page with all the results of people that are offering the job that he is searching.

2
  • 1
    can you provide a sample of the results you want Commented Apr 29, 2014 at 16:27
  • Cant get your objective from this Commented Apr 29, 2014 at 16:40

1 Answer 1

2

This will get you all user offering skills which are searching. Try it:

SELECT o.* FROM Table1 s 
INNER JOIN Table1 o 
ON s.job = o.job
WHERE s.type = 'searching'
AND o.type = 'offering'
AND s.user_id = (The user who is searching)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.