MYSQL选择已加入的表并仍然显示未加入的行如果ID相同

时间:2016-05-12 09:28:06

标签: mysql

我正在加入一个BID应用程序表。 我有两个表格// CLIENT-SIDE Code (may be a web browser) // You have just sent a request to the server.. // ..with user credentials for authentication in the request body // in the request body may be a window.FormData object or a json etc. http.post('auth', userCredentials) // probably the request mechanism you make http.. // ..requests asynchronously, maybe using a library,.. // ..will return a Promise, and you will have a similar code below. .then(response => { response.json() .then(responseJson => { // set localStorage with your preferred name,.. // ..say 'my_token', and the value sent by server window.localStorage.setItem('my_token', responseJson.my_token) // you may also want to redirect after you have saved localStorage: // window.location.assign("http://www.example.org") }) }) BIDS。(我也有人投标人表) 这只是表格的一个示例: 订单表:

ORDERS

BIDS TABLE:

OrderID | Item  | OrderStatus|
________|_______|____________|
    1   |Shoes  | On-Bidding |
    2   |Bag    | On-Bidding |
    3   |Shirt  | On-Bidding |

我想要的是向投标人显示他可以为特定投标人同时出价以及他的出价。 例如:

对于投标人ID 2:

__________________________________________________
BidID | BidCost | BidStatus |BidderID  |OrderID  |
______|_________|___________|__________|_________|
  1   | $100    |Waiting    | 2        |2        |
  2   | $200    |Waiting    | 1        |2        |

对于投标人ID 1

Order ID| Item  | BidCost |
2       |Bag    | $100    |
1       |Shoes  | NULL    |
3       |Shirt  | NULL    |

对于投标人ID 3(他没有投标)

Order ID| Item  | BidCost |
2       |Bag    | $200    |
1       |Shoes  | NULL    |
3       |Shirt  | NULL    |

我现在所拥有的是当有人竞标某个特定项目时,其他用户的BidCost会向另一个用户显示。我使用了UNION来获取所有的NULL值,但它也显示了一个订单,即使你已经对它进行了BID就像

一样
Order ID| Item  | BidCost |
2       |Bag    | NULL    |
1       |Shoes  | NULL    |
3       |Shirt  | NULL    |

0 个答案:

没有答案