select-statement

How do I provide a string of Ids in a Select statement's IN clause even though the column is an integer

I'm paging data using an ObjectDataSource and I have the following method: public int GetNumberOfArticles(string employeeIds) { System.Data.DataTable dataTable; System.Data.SqlClient.SqlDataAdapter dataAdapter; System.Data.SqlClient.SqlCommand command; int numberOfArticles = 0; command = new System.Data.SqlClient.S...

How to use the LIKE statement correctly in a MySql SELECT statement?

Why isn't this working? DELIMITER ;// CREATE PROCEDURE `blah` ( SearchText varchar(4000) ) BEGIN SELECT * FROM table_name WHERE table_name.StringField LIKE '%' + SearchText + '%'; -- This is where the code is breaking END;// ...

SQL: Use multiple values in single SELECT statement

I'm using a SELECT statement in T-SQL on a table similar to this: SELECT DISTINCT name, location_id, application_id FROM apps WHERE ((application_id is null) or (application_id = '4')) AND ((location_id is null) or (location_id = '3')) This seems to work fine when searching for one application_id or one location_id, but what if I want...

How do you implement a select statement in VBScript?

Can anyone please tell me how to implement select statements in VBScript, similar to switch statement in C? It would be great if you provided some examples as I'm pretty new to VBScript. Thanks. ...

Is there a reason to prefer a switch over an if statement with only one condition?

I found the following code in my team's project: Public Shared Function isRemoteDisconnectMessage(ByRef m As Message) isRemoteDisconnectMessage = False Select Case (m.Msg) Case WM_WTSSESSION_CHANGE Select Case (m.WParam.ToInt32) Case WTS_REMOTE_DISCONNECT isRemoteDisconnect...

SQLAlchemy sqlalchemy.sql.expression.select vs. sqlalchemy.sql.expression.Select

So I'm brand new to SQLAlchemy, and I'm trying to use the SQL Expression API to create a SELECT statement that specifies the exact columns to return. I found both a class and a function defined in the sqlalchmey.sql.expressions module and I'm not too sure which to use... Why do they have both a class and a function? When would you use on...

Select ancestors and immediate children of a node in a nested set tree using MYSQL

Hoping some of you mysql experts can help me out. I have searchtag data that is stored in a nested set. TABLE searchTags searchTagID searchTag lft rgt (I am using nested sets because there are times when I need to easily select entire branches of the tree.) I would like to construct a query that will return a resultset of nodes ...

How do I make the following interaction with mySQL more efficient?

I've got an array that contains combinations of unique MySql IDs: For example: [ [1,10,11], [2,10], [3,10,12], [3,12,13,20], [4,12] ] In total there are a couple hundred different combinations of IDs. Some of these combinations are "valid" and some are not. For example, [1,10,11] may be a valid combination, whereas [3,10,12] m...

SQL Server 2000, Get COUNT(DISTINCT ID) with a condition that I can't write to my WHERE ?

Hello all, First of all, I don't want to use a "join" because that will make my query longer and difficult to read. So what I need to do must be withing the same SELECT statement. My columns in myTable are A, B , C , D , time, ID and H H columnd tells if a record is 'Open' or 'Close', here how my query looks like. SELECT A, B, C, ...

How can I make an SQL statement that finds unassociated records?

I have two tables as follows: tblCountry (countryID, countryCode) tblProjectCountry(ProjectID, countryID) The tblCountry table is a list of all countries with their codes and the tblProjectCountry table associates certain countries with certain projects. I need an SQL statement that gives me a list of the countries with their country...

In mySQL, Is it possible to SELECT from two tables and merge the columns?

If I have two tables in mysql that have similar columns... TABLEA id name somefield1 TABLEB id name somefield1 somefield2 How do I structure a SELECT statement so that I can SELECT from both tables simultaneously, and have the result sets merged for the columns that are the same? So for example, I am hoping to do some...

SQL Get specific columns from one table and all rows from a joined table in one query

This may have been asked before and I just can't find it. I have a one to many relationship in the database on a few tables. table1 table2 table3 table2 - table3 is the 1-many relationship here's a mock of what I have: select table1.id table1.Column table2.Column2 -- I want all entries here from table 3 here as well From table1 t...