0

I have two tables. Table_1 have this fields.

table_1_id
name
image
adres

Table_2

table_2_id
name
email
phone
comment
datetime
need_id

I want to make when I click on the ID_1 form table_1 to load me all rows from table_2 which have table_1_id = 1 I've tried with this query

SELECT t1*, t2.* FROM table_1 t1, table_2 t2
                 WHERE t1.table_1_id = t2.need_id ORDER BY `DateTime` DESC

and show blank page. Then I tried like this

SELECT t1.*, t2.* FROM table_1 t1
 JOIN table_2 t2 ON t1.table_1_id = t2.need_id ORDER BY ` DateTime` DESC 

This whatever I click is returned first 5 results from database and that's it.

1 Answer 1

1

Assuming you have ID_1, you don’t need to involve table_1 in the query:

SELECT * FROM table_2
WHERE need_id = ID_1 
ORDER BY `DateTime` DESC 
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.