How can I seach for multiple values of a single field in youtrack? - youtrack

I'm trying to do the equivalent of a "where in" search in youtrack. I have a list of values and I want to know how to do that other than just saying:
field: value or field: value2 or field: value3

A shortcut form would be #value1 #value2 #value3. The thing is that when you enumerate several values belonging to the same catogory (say, values of a field), the values are ORed.

Related

Use auto generated id in another field

In some cases we need to duplicate the auto generated id field into another field of the same row.
Is there a way to do this with one INSERT statement instead of going back and doing an update afterwards?
Here's some none working SQL to illustrate what I'm trying to do:
INSERT INTO someTable (string1, string2, int1)
VALUES ('foo', 'bar', id)
Attempting to put the auto generated id into the field 'int1'
try to use sequence like it shown in this link NEXT VALUE FOR

sql insert only two values into a table with 10 fields

My table has 10 fields: field1, field2,..., field10
Now suppose i only want to insert values into first two columns, and put '' on the rest.
I'm currently using
insert into table1 values
(100,200,'','','','','','','','','','')
I wonder if there is a better way to avoid ,'','','','' ?
Thanks for advice!
Yes, just specify the fields you want to add like this:
insert into table1 (field1, field2) VALUES (100,200)
In this case field1 will insert 100, and field2 will insert 200.
The other fields in your table will be null, so you need to make sure that is allowed.
EDIT:
in the comments, #andreas is correct - any field you don't specify will be given it's default value (which may be null)

Get values based on newly inserted value using SQL

I want to make filtration on a column after selecting a specific value of another column in the same table, I tried to use #... special character followed by the column's name to get the address of this value.
My SQL statement is like the following :
SELECT ATTRIBUTE FROM TABLE WHERE FIELD = '#FIELDNAME';
If I used a specific value instead of #FIELDNAME, it will work properly but it will be static but I need it to be dynamic based on the selected value.
Create another table which will have the list of values that are in the FIELDNAME and give each record a unique id ,then retrieve the value depending on what you have selected by the name of the new table's field preceded by '#...'
I don't know if that what are you looking for, please let me know.
If no triggers are allowed, do you have any date/time column in the table? Is it possible to have that extra column anyway to see the time of a newly inserted row?
You may have to check the lastest row entered, save its field value into a variable. Then do the select based on the variable value.
Based on the vague last row id you could try the following (it's not pretty). But again, if you have date/time that's more accurate.
select attribute from table
where field = (select field from table
where rowid =(select max(rowid) from table))
;
upate
Do you have the priviledge to set up your insert command as below:
insert into table (id, col1, col2,...) values (1,'something', 'something',...)
returning id into variable; -- you may either save field or id depending on your table
Then you may use this variable to select the records you want.

How to determine of an SQL table row contains values other than NULL

This is the problem:
I have a table with unknown number of columns. all the columns are real.
Assuming there is only one row in that table, I need a method to determine if there is a value other than NULL in that table/row.
I don't know the number of columns nor their name at run-time (and don't want to use c cursor)
SQL Server 2005
I appreciate your help.
Here's one way - CHECKSUM() returns no value if all values in the row are NULL:
create table #t (col1 real, col2 real, col3 real)
select checksum(*) from #t
if ##rowcount = 0
print 'All values are NULL'
else
print 'Non-NULL value(s) found'
drop table #t
On the other hand, I don't really know if this is what you're doing: a "temporary table built in memory" sounds like something you're managing yourself. With more information about what you're trying to achieve, we might be able to suggest a better solution.
And by the way, there is nothing wrong with a single-row table for storing settings. It has the big advantage that each setting has a separate data type, can have CHECK constraints etc.
Sounds like you're doing some kind of a settings/properties table, based on the fact that you know you only have 1 row in it. This is the wrong way to do it, if you need to have dynamic properties; instead have a table with 2 columns: option and value. Then for each dynamic property, you'll store one row.

vbscript/sql adding a column to an insert statement

I am trying to add an additional column and value to an existing insert query - both integers, and running into trouble.
Anything to look out for?
you don't give much to go in in your question:
I am trying to add an additional
column and value to an existing insert
query - both integers, and running
into trouble.
Anything to look out for?
it is best practice to list all columns you intend to include values for in the list of columns, so make sure you add them there, as well as the VALUES list:
insert into YourTable (col1, col2,..., newCol1, newCol2)
VALUES (1,2,...,new1, new2)
make sure the you get the column names spelled correct and that the table actually has those new columns in it.
make sure the column name sequence is the same as your insert data sequence.
Example
INSERT INTO TABLENAME
(ColumnName1,ColumnName2) VALUES (1,'data')
Becomes
INSERT INTO TABLENAME
(ColumnName1,ColumnName2,ColumnNameNEW) VALUES (1,'data','newcolumndata')
Notice both the new column name and the new data are in the third position in the sequence.