SELECT id_one, id_two, timestamp_one, timestamp_two
FROM tablename
WHERE id_one = 27
OR id_two = 27
ORDER BY
CASE
WHEN id_one=27 THEN timestamp_one
WHEN id_two=27 THEN timestamp_two
END DESC
More Related Contents:
- How to use IN & NOT IN same query [closed]
- SQL Print the name of all Employees together with the name of their supervisor
- Syntax error due to using a reserved word as a table or column name in MySQL
- Change MySQL default character set to UTF-8 in my.cnf?
- MySQL: Large VARCHAR vs. TEXT?
- MySQL offset infinite rows
- Multiple-column foreign key in MySQL?
- What is the question mark’s significance in MySQL at “WHERE column = ?”?
- How do write IF ELSE statement in a MySQL query
- mysql – making a mechanism similar to Oracle’s seqences
- How do you uninstall MySQL from Mac OS X?
- Difference between VARCHAR and TEXT in MySQL [duplicate]
- Get the latest date from grouped MySQL data
- How to program a MySQL trigger to insert row into another table?
- UUID performance in MySQL?
- MySQL: NULL vs “”
- Optimal MySQL settings for queries that deliver large amounts of data?
- Invalid default value for ‘dateAdded’
- Importing a CSV to MySQL with different date format
- MySQL: When is Flush Privileges in MySQL really needed?
- MySQL too long varchar truncation/error setting
- MySQL: update a field only if condition is met
- how to use DISTINCT ON with mysql using ActiveRecord
- use a variable for table name in mysql sproc
- How to create dummy variable columns for thousands of categories in Google BigQuery?
- Most efficient way to store IP Address in MySQL [duplicate]
- What is the best way to do incremental backups in MySQL?
- List of Constraints from MySQL Database
- MySQL Recursive get all child from parent
- How do I extract Month and Year in a MySQL date and compare them?