开发者

"Union" Table in MYSQL

开发者 https://www.devze.com 2023-03-12 00:03 出处:网络
$num = mysql_query(\"(SELECT id,room_type,JUNE1 From JU开发者_如何学编程NE WHERE table_type = \'disp\' AND id = 78 AND JUNE1!=0)
$num = mysql_query("(SELECT id,room_type,JUNE1 
                     From JU开发者_如何学编程NE 
                     WHERE table_type = 'disp' AND id = 78 AND JUNE1!=0) 

                    UNION ALL 

                    (SELECT id,room_type,JULY1 
                     From JULY 
                     WHERE table_type = 'disp' AND id = 78 AND JULY1!=0)");

I am using this script for getting the combined value, We are getting the value in this type .

ID | Value
78 | 12
78 | 08

In above table the query show the one row for JUNE table, and second row for JULY data, we only want to display single month data, but it check the data in second table... like the above query is working fine for me. but it print double records, ID 78 for JUNE, ID 78 for JULY, we only want to print single ID like below.

ID | Value
78 | 08

Thanks

Rod

0

精彩评论

暂无评论...
验证码 换一张
取 消