I have a list of ISO2 country codes I want to use in a query.
Something like this:
select cou, 128,13, 1
from ('AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', [snip]) as cou
But.. working.
I remember doing such a thing in the past, but I can't find any doc about it anymore. It's a one shot query so I don't mind performance, coding practice or maintainability.
Any ideas?
UPDATE
As Pax noted, it is indeed better practice to have this data in my database for all the good reasons. I understand his opinion because I would answer the same. However, this data already IS in another table, in another database, on another server, on another network..
In order to test my queries I need some quick shot values in a table on this new database. I don't want to configure networks, cross-server queries etc just to test my queries on some real-life data. I hope this explains why I go against the stream for this one shot.
Can we use list in SQL? You can create lists of SQL Query or Fixed Data values .
Hardcoding is the practice of making code tailored to handle very specific cases. Here are some examples of hardcoding as applies to Drupal: Inserting an SQL query into a . tpl file. Writing a script that queries the database to make some changes to nodes.
To create a list query from the selected column, right-click on the column and select 'Add as New Query' option as shown in the picture below. NOTE: You can also use Table. ToList() function in Power Query (M) language for creating a list from a data table.
Values keyword can be used to achieve this.
select col1, 128 col2, 13 col3, 1 col4
from ( values ('AD'), ('AE'), ('AF'), ('AG'), ('AI'), ('AL'), ('AM')) as x (col1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With