douqiang3768 2012-12-05 06:16
浏览 33
已采纳

PHP mysql在同一页面上选择数据多个表

There are two mysql tables like this:

table 1

--id-----config_name
--1-----OS
--2-----Control Panel
--3-----Bandwidth

table 2

id -- config_id--- config_Option_name --- Price
1--------1-------------Windows 2008--------20.00
2--------1-------------CentOs 5----------------0.00
3--------2-------------whm/cPanel-----------30.00
4--------2-------------Plesk-------------------50.00


Now I want to show them like this:

OS
Windows 2008 = 20.00
CentOs 5 = 00.00
Control Panel
whm/cPanel= 30.00
Plesk = 50.00

Please help me to do that.

  • 写回答

3条回答 默认 最新

  • doujiayuan8415 2012-12-05 06:19
    关注

    Try this :

    Select config_name, config_Option_name, price 
    
    from table1 
    inner join table2 on (table1.id=table2.config_id)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?