Questions tagged [select-query]
176 questions
327
votes
16 answers
How can I select from list of values in SQL Server
I have very simple problem that I can't solve. I need to do something like this:
select distinct * from (1, 1, 1, 2, 5, 1, 6).
Anybody can help??
Edit
The data comes as a text file from one of our clients. It's totally unformatted (it's a single,…

Eedoh
- 5,818
- 9
- 38
- 62
130
votes
10 answers
SELECT * FROM tablename WHERE 1
I've been curious. What are the differences between these respective queries:
SELECT * FROM `tablename`
SELECT * FROM `tablename` WHERE 1
SELECT * FROM `tablename` WHERE 1=1

Stephen Alexander
- 1,283
- 2
- 8
- 6
86
votes
11 answers
SQL Server PRINT SELECT (Print a select query result)?
I am trying to print a selected value, is this possible?
Example:
PRINT
SELECT SUM(Amount) FROM Expense

Shimmy Weitzhandler
- 101,809
- 122
- 424
- 632
31
votes
3 answers
Using an IF Statement in a MySQL SELECT query
I am trying to use an IF statement in a MySQL select query.
I am getting an error after the AND statement where the first IF.
SELECT…

Santosh
- 2,355
- 10
- 41
- 64
26
votes
8 answers
MySQL floating point comparison issues
I ran into an issue by introducing floating point columns in the MySQL database schema that the comparisons on floating point values don't return the correct results always.
1 - 50.12
2 - 34.57
3 - 12.75
4 - ...(rest all less than 12.00)
SELECT…

Sharief Shaik
- 1,064
- 5
- 12
- 26
15
votes
3 answers
persian/arabic search in sqlite android gives bad result
i have a problem with sqlite database. it seems to not support full persian/arabic characters. when i search some fields based on persian chars, most of the times Sqlite can't recognize those chars.
i insert data into database by copy them from HTML…

hojjat reyhane
- 648
- 1
- 8
- 25
4
votes
2 answers
what will be the select query for excluding empty values in ms access
I am trying
select * from table where Contact Is Not null
but it is displaying values including empty values

Vampire
- 320
- 1
- 4
- 10
4
votes
2 answers
Misuse of aggregate function MAX()
I want latest not null value of column ignition_status in Alert table.
I have column unix_time which is time in Unix Time Stamp, so max the unix_time column value, latest is the entry.
Below is my code
cursor = dbUtilsObj.query(Alert.TABLE_NAME,…

Shirish Herwade
- 11,461
- 20
- 72
- 111
4
votes
1 answer
Wildcard as parameter of stored procedure
Suppose, I have a stored procedure, that accepts one parameter - id, and returns some data corresponding to this id. What if I want to retrieve all such data, like using wildcard in SELECT query? How to do this?

Andrew Vershinin
- 147
- 3
- 3
- 10
4
votes
3 answers
SQL query confusion for startdate and enddate
I have a table(e.g. tableA) like this:
| Name | Startdate | Enddate |
|---------------------------------|
| a | 2012-07-01 | 2013-06-30 |
| b | 2011-05-01 | 2012-04-30 |
| c | 2010-01-01 | 2013-12-31 |
| d | 2013-01-01 |…

Himanshu
- 31,810
- 31
- 111
- 133
3
votes
2 answers
MYSQL select query using count (*)
i have a problem concerning a select query in MYSQL
i have two different tables and i want to obtain a certain result
i used COUNT method which gave me only the results (>=1)
But in reality , i want to use all counts with zero included how to do…

holy
- 632
- 2
- 9
- 18
3
votes
2 answers
PL/SQL - Select columns values as string array
I am not sure if this question is asked anywhere else before. I am not sure how to put it also. But I will explain with a scenario.
I have the following tables
TAB1 with columns : USERID, CODE, COUNTRY
TAB2 with columns : USERID, CODE, EMAIL
Example…

Rishi P
- 249
- 2
- 9
- 20
3
votes
4 answers
Return result of select query only if not empty
Working with Sql Server. Writing a stored procedure. Here is the pseudocode for what I want to achieve:
IF EXISTS ( SELECT field1
FROM t1
WHERE field1 = ... AND field2 = ...)
BEGIN
…

Chirayu Shishodiya
- 544
- 2
- 7
- 14
3
votes
3 answers
Select data from the last hour, MS Access
I am working on doing some data transfers moving data from one database to another and I would like to do this without using to much memory on the computer that I am running this data transfer program on. Currently the program is ran every minute,…

LaDante Riley
- 521
- 4
- 14
- 26
3
votes
1 answer
Spark: load or select Hive table of ORC format
I'm trying to load a managed hive table created in ORC format with spark sql.
SparkConf conf = new SparkConf().setAppName(ConnectionTest.class.getName()).setMaster(master);
JavaSparkContext context = new JavaSparkContext(conf);
SQLContext…

josele
- 97
- 2
- 11