Selecting data from two different tables of the same database in PHP/ MYSQL

Programming Geek

I have 2 different tables SECTION and SUBSECTION in a database QUIZ. The SECTION table has 2 columns section_id and section_title, whereas SUBSECTION table has 4 columns section_id, subsection_id(AI), subsection_title, subsection_detail. Now, what I want is that the section_title but the table that needs to be queried is the SUBSECTION table and with the help of the section_id from the SUBSECTION table we would have to fetch the section_title from the SECTION table.

I have tried some of the solutions given over here but I don't know why these aren't working for me. Any help here would be highly appreciated.

Marjan

You could use IN in a way that the results from one query can be passed to another.

Perhaps this is an idea:

SELECT section_title FROM section WHERE section_id IN (SELECT section_id FROM subsection WHERE [some condition here to get the correct set of ids from subsection table])

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL selecting from two tables in the same query

From Dev

MySQL- Selecting data from different tables

From Dev

MySQL- Selecting data from different tables

From Dev

selecting the same data in different row from database

From Dev

Echo data from two different mysql tables using php

From Dev

MySql selecting ids from two different tables by other elements then ids

From Dev

PHP/MySQL INSERT same data INTO two Tables

From Dev

PHP/MySQL INSERT same data INTO two Tables

From Dev

MySQL & PHP: Divide two numbers from two different tables with the same date

From Dev

MySQL & PHP: Divide two numbers from two different tables with the same date

From Dev

Selecting all records from two different tables

From Dev

Display data from two tables - PHP mySQL

From Dev

Database Selecting two tables

From Dev

Refer two database tables in same query in php/mysql

From Dev

How can I store the same data in two different mySQL tables?

From Dev

Counting and selecting data from two tables

From Dev

Selecting data from two tables with sql query

From Dev

Counting and selecting data from two tables

From Dev

fetch data from two different tables on same textbox changed event

From Dev

Get data from two different tables in the same query

From Dev

MySQL selecting data from 2 tables

From Dev

Selecting nested data from multiple MYSQL tables

From Dev

MySQL select count different data from same tables Best approach

From Dev

Selecting data from two mysql tables where there may be nonexistent data in second table

From Dev

Matching two columns from different tables - MySQL PHP

From Dev

How to link and display MySQL data from two different tables?

From Dev

PHP collect and combine different data from two tables

From Dev

SQL server 2008, get a new table by selecting two columns from two different tables that do not share same column information

From Dev

SQL server 2008, get a new table by selecting two columns from two different tables that do not share same column information

Related Related

  1. 1

    MySQL selecting from two tables in the same query

  2. 2

    MySQL- Selecting data from different tables

  3. 3

    MySQL- Selecting data from different tables

  4. 4

    selecting the same data in different row from database

  5. 5

    Echo data from two different mysql tables using php

  6. 6

    MySql selecting ids from two different tables by other elements then ids

  7. 7

    PHP/MySQL INSERT same data INTO two Tables

  8. 8

    PHP/MySQL INSERT same data INTO two Tables

  9. 9

    MySQL & PHP: Divide two numbers from two different tables with the same date

  10. 10

    MySQL & PHP: Divide two numbers from two different tables with the same date

  11. 11

    Selecting all records from two different tables

  12. 12

    Display data from two tables - PHP mySQL

  13. 13

    Database Selecting two tables

  14. 14

    Refer two database tables in same query in php/mysql

  15. 15

    How can I store the same data in two different mySQL tables?

  16. 16

    Counting and selecting data from two tables

  17. 17

    Selecting data from two tables with sql query

  18. 18

    Counting and selecting data from two tables

  19. 19

    fetch data from two different tables on same textbox changed event

  20. 20

    Get data from two different tables in the same query

  21. 21

    MySQL selecting data from 2 tables

  22. 22

    Selecting nested data from multiple MYSQL tables

  23. 23

    MySQL select count different data from same tables Best approach

  24. 24

    Selecting data from two mysql tables where there may be nonexistent data in second table

  25. 25

    Matching two columns from different tables - MySQL PHP

  26. 26

    How to link and display MySQL data from two different tables?

  27. 27

    PHP collect and combine different data from two tables

  28. 28

    SQL server 2008, get a new table by selecting two columns from two different tables that do not share same column information

  29. 29

    SQL server 2008, get a new table by selecting two columns from two different tables that do not share same column information

HotTag

Archive