You can use LEAST
and GREATEST
function to achieve it.
SELECT
GREATEST(A.date0, B.date0) AS date0,
LEAST(A.date1, B.date1) AS date1
FROM A, B
WHERE B.x = A.x
Both are described here http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html
More Related Contents:
- get first occurrence of last changed value of a column [closed]
- INSERT INTO SELECT statement with more columns which is not in another table
- multiple query same table but in different columns mysql
- How can I make SQL case sensitive string comparison on MySQL?
- 1052: Column ‘id’ in field list is ambiguous
- How can I temporarily disable a foreign key constraint in MySQL?
- How to do a batch insert in MySQL
- Count the occurrences of DISTINCT values
- Creating a “Numbers Table” in MySQL
- Why does MySQL allow “group by” queries WITHOUT aggregate functions?
- Cumulative sum over a set of rows in mysql
- Set NOW() as Default Value for datetime datatype?
- In SQL, how to select the top 2 rows for each group
- Add Auto-Increment ID to existing table?
- MySQL SELECT DISTINCT multiple columns
- SQL DELETE with JOIN another table for WHERE condition
- mysql trigger stored trigger is already used by statement which invoked stored trigger
- Error Dropping Database (Can’t rmdir ‘.test\’, errno: 17)
- Using group by on two fields and count in SQL
- mysql update query with sub query
- What is the difference between the backtick and the square bracket in SQL statements?
- MySQL CONCAT returns NULL if any field contain NULL
- Integrity constraint violation: 1452 Cannot add or update a child row:
- How to insert a file in MySQL database?
- What does SQL Select symbol || mean?
- Using DISTINCT and COUNT together in a MySQL Query
- How to check if field is null or empty in MySQL?
- MySQL OPTIMIZE all tables?
- Strip last two characters of a column in MySQL
- Deleting a row based on the max value