douzhan1963 2011-05-16 08:51
浏览 27

我想进行查询,从几个表中检索多个列

I want something in PHP-mysql

I want to make one query, retrieve several or all columns from several tables

Example

query 1: "SELECT * FROM table1"
query 2: "SELECT * FROM table2"
query 2: "SELECT id,name FROM table3"
query 2: "SELECT num,num2 FROM table4"

And so on If you want to add more .

I want to combine all these queries in a single query .

Note: All queries doesn't associated with some, and also I do not want a problem occurs if the table is empty .

any helper here to help me

  • 写回答

5条回答 默认 最新

  • douxie2023 2011-05-16 08:56
    关注

    You need is some way to join the data together for example a column that exists in both tables that is common to each table

    eg Accomodation database of sudents

    Accomodation_table Accomodation_ID | Accomodation_Name

    Student Table Student_ID | Student_Name | Accomodation_ID

    Accomodation_ID is the common field

    the query would look like this

    Select a.Accomodation_Name, b.student_name
    from Accomodation_table a, Student_Table b
    where a.Accomodation_ID = b.Accomodation_ID
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)