Skip to content Skip to sidebar Skip to footer

Mysql Select All Values Which Share This Field's Value

I am new to MySQL so describing problems in words is difficult and searching for solutions is extremely challenging. This problem is best explained visually: I want to select (as a

Solution 1:

I am thinking a query like this , but I'm waiting your answer at comments. Basically, you use GROUP BY to obtain in two different columns the values for each pair_id:

SELECT pair_id, MIN(exhange_pair_id) AS id1, MAX(exchange_pair_id) AS id2
FROM yourtable
GROUPBY pair_id;

Update version: Can you try this please on your data? In this case MYSQL let you concat field using a separator (,)

SELECT pair_id, GROUP_CONCAT(exhange_pair_id) AS exhange_pair_id 
FROM yourtable
GROUPBY pair_id

Solution 2:

try select exchange_pair_id from yourtable where pair_id=1 then it will return array [1,183]

Solution 3:

The SQL you are looking for would be:

SELECT*WHERE pair_id ==1

Without knowing what your specific code looks like, I can only guess as to how you are implementing a call to your database. I would assume you are doing some sort of async call to a PHP controller. So instead of using '1' in the query, you will need to use whatever variable you are pulling from your code to know what you are looking for.

Post a Comment for "Mysql Select All Values Which Share This Field's Value"