2016-05-02 2 views
0

偽の行を追加します私はresulを希望は私のクエリがある

Email   Price 
[email protected] 84,00 
[email protected] 99,00 
[email protected] 29,00 
[email protected] 99,00 

結果白値打ち価格'21 .00'

ノーマル結果このようなT:

Email   Price 
[email protected] 84,00 
[email protected] 99,00 
[email protected] 21,00 
[email protected] 29,00 
[email protected] 99,00 
[email protected] 21,00 
+1

偽の行をテーブルに追加するのか、SELECTだけに追加しますか? – MontyPython

+2

PRIMARY KEYとは何ですか? – Strawberry

+0

選択のみのための挿入 – user3684020

答えて

1

使用(順番に修正)と予想を取得するには、以下のクエリは、このクエリを使用する場合は、順序で結果を得ることはありません を結果

Email   Price 
[email protected] 84,00 
[email protected] 99,00 
[email protected] 21,00 
[email protected] 29,00 
[email protected] 99,00 
[email protected] 21,00 

しかし、あなたを使用するクエリが

SELECT email,price 
FROM invoice 
WHERE email='[email protected]' 
UNION ALL 
SELECT email,21,00 
FROM invoice 
WHERE email='[email protected]' 
AND Price=99,00 
であるため

Email   Price 
[email protected] 84,00 
[email protected] 99,00 
[email protected] 29,00 
[email protected] 99,00 
[email protected] 21,00 
[email protected] 21,00 

以下になります

+0

COOLです。あなたは仲がいい! – user3684020

関連する問題