Created
February 17, 2021 10:09
-
-
Save g105b/901736764b6940c0eff053928c941706 to your computer and use it in GitHub Desktop.
Converting a MySQL question mark parameter to a named parameter for reuse in the same query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
(@param1 := ?), | |
value, | |
timestamp, | |
Field.name, | |
Site.id | |
from | |
Field_Value | |
inner join | |
Site_Field | |
on | |
id_Site_Field = Site_Field.id | |
inner join | |
Site | |
on | |
id_Site = Site.id | |
where | |
(@param1 is null | |
or Site.id = @param1) | |
order by | |
id desc | |
limit 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment