'How to get uncommon column values associated with two different rows in a MYSQL table
I am trying to query a table with millions of rows using PHP not SQL.
Select B from table where A=1 & C=1 & not present wherever A=2
In the example table the requested B value is 5.
I want to get a value from column B with a column A value of 1 and column C value of 1 if this column B value is not also present where column A value is 2.
Thanks.
Table
+-+-+-+
|A|B|C|
+-+-+-+
|1|3|0|
+-+-+-+
|1|6|0|
+-+-+-+
|1|5|1|
+-+-+-+
|2|3|1|
+-+-+-+
|2|4|1|
+-+-+-+
|3|3|0|
+-+-+-+
Solution 1:[1]
you can try this
SELECT B FROM(
select B, COUNT(B) CNT
from test
WHERE A IN (1,2)
GROUP BY B)X WHERE CNT=0 OR CNT=1;
Solution 2:[2]
Skip all this networking futzing and setup port forwards. You can tell VirtualBox to map port 1521 on your host to port 1521 on the vm, so SQL Developer can simply connect to localhost:1521/database in your connection.
I talk about this in more details here
Disclaimer: I'm the product manager at Oracle for SQL Developer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amit Verma |
| Solution 2 | thatjeffsmith |

