mrherman Posted November 8, 2010 Share Posted November 8, 2010 JUDDSTER suggested this query to solve a problem. What purpose do the colons have before "current_slot"? Thanks. SELECT SlotID FROM ( SELECT SlotID AS SlotRank, SlotID FROM UserSeats WHERE slot > :current_slot UNION SELECT SlotID + 8 AS SlotRank, SlotID FROM UserSeats WHERE slot <= :current_slot ) ORDER BY SlotRank Link to comment https://forums.phpfreaks.com/topic/218053-colons-in-mysql-query-first-time-ive-seen-this/ Share on other sites More sharing options...
mikosiko Posted November 8, 2010 Share Posted November 8, 2010 They are called "Named Parameters".... they are used in prepared statements . Depending of which extension are you using... PDO , Mysql, Mysqli, etc. they can be accepted or not... In mysqli the "?" is the equivalent and it is used like this: SELECT SlotID FROM ( SELECT SlotID AS SlotRank, SlotID FROM UserSeats WHERE slot > ? UNION SELECT SlotID + 8 AS SlotRank, SlotID FROM UserSeats WHERE slot <= ? ) ORDER BY SlotRank Search for "Mysql Prepared Statements" to learn more. Link to comment https://forums.phpfreaks.com/topic/218053-colons-in-mysql-query-first-time-ive-seen-this/#findComment-1131615 Share on other sites More sharing options...
mrherman Posted November 8, 2010 Author Share Posted November 8, 2010 Thanks very much for the information! Very helpful. Link to comment https://forums.phpfreaks.com/topic/218053-colons-in-mysql-query-first-time-ive-seen-this/#findComment-1131802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.