Rajveer
Rajveer

Reputation: 857

SQL and temporary row in SELECT query

I'm using a custom combobox class which populates from a database with an SQL query as such:

playerCB->setDatabaseQuery("SELECT player.id, player.name FROM player WHERE player.team_id = " + QString::number(teamID) + " ORDER BY player.name;");

(internally this class keeps all selected values for each returned row).

I would like to add a temporary row to the results where player.id = -1 and player.name = (Custom Player), however these should not exist within the database. It should be done with using SQL queries only as I can't make any changes to the combobox class. How would I go about doing this, would I have to use temporary tables or something?

Upvotes: 1

Views: 3524

Answers (1)

Marcus Adams
Marcus Adams

Reputation: 53830

You can use literal values like this:

SELECT -1 AS id, '' AS name

Upvotes: 5

Related Questions