I need to connect 2 columns to 1 column, but I can't figure it out how to connect those columns. This is how it looks like:
Table(appointment)
-------------------------------------------
| id | home | salesman | buyer | date |
| 1 | 3 | 2 | 4 | 12-6-2016|
| 2 | 1 | 1 | 3 | 15-6-2016|
| 3 | 2 | 5 | 6 | 20-6-2016|
-------------------------------------------
Table(person)
---------------------------------------------------------
| id | name | email | phonenumber | permission |
| 1 | John | John@gmail.com | 12345678 | 1 |
| 2 | Jack | Jack@gmail.com | 12345678 | 1 |
| 3 | Henk | Henk@gmail.com | 12345678 | 0 |
| 4 | Mike | Mike@gmail.com | 12345678 | 0 |
| 5 | Tom | Tom@gmail.com | 12345678 | 1 |
| 6 | Ben | Ben@gmail.com | 12345678 | 0 |
---------------------------------------------------------
Table(home)
----------------------------------------------
| id | salesman | price | buyer | city |
| 1 | 2 | 123000 | 4 | London |
| 2 | 1 | 123000 | 3 | New York |
| 3 | 5 | 123000 | 6 | Paris |
----------------------------------------------
This is how I want to see it on my php page:
-------------------------------------------------
| home | salesman | buyer | date |
| Home in Paris | Jack | Mike | 12-6-2016|
| Home in London | John | Henk | 15-6-2016|
| Home in New York| Tom | Ben | 20-6-2016|
-------------------------------------------------
People with permission 1 are salesman, permission 0 are buyers.
So my question is, how can I change the numbers to the correct value? Without change the number in table appointment to values in the database...
I don't know much about SQL, so could someone please come with a solution that isn't an example and works with my tables and columns?
Aucun commentaire:
Enregistrer un commentaire