SELECT @id :=
(
SELECT senderid
FROM mytable
WHERE receiverid = @id
) AS person
FROM (
SELECT @id := 5
) vars
STRAIGHT_JOIN
mytable
WHERE @id IS NOT NULL
More Related Contents:
- How to create a MySQL hierarchical recursive query?
- Generating Depth based tree from Hierarchical Data in MySQL (no CTEs)
- Is it possible to query a tree structure table in MySQL in a single query, to any depth?
- Getting all parent rows in one SQL query
- Fetching linked list in MySQL database
- Implementing a hierarchical data structure in a database
- MySQL Recursive get all child from parent
- MySQL Closure Table hierarchical database – How to pull information out in the correct order
- Recreating a query using INNER JOIN? [duplicate]
- MySQL: Enable LOAD DATA LOCAL INFILE
- SQL order string as number
- MySQL: Fastest way to count number of rows
- Find most frequent value in SQL column
- Rails 3 ActiveRecord: Order by count on association
- update multiple rows using limit in mysql?
- Speeding up row counting in MySQL
- MySQL ENUM type vs join tables
- How to detect UTF-8 characters in a Latin1 encoded column – MySQL
- MySQL – How to SUM times?
- How do I UPDATE a row in a table or INSERT it if it doesn’t exist?
- mysql root password forgotten
- In MySQL, can I defer referential integrity checks until commit
- Converting epoch number to human readable date in mysql
- How to make join queries using Sequelize on Node.js
- mysql like performance boost
- MySQL 5.6 – DENSE_RANK like functionality without Order By
- MySQL: Can I do a left join and pull only one row from the join table?
- How can I “select *” from a table in MySQL but omit certain columns?
- For homebrew mysql installs, where’s my.cnf?
- MySQL Select Multiple VALUES