Questions tagged [select-query]
178 questions
244
votes
15 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,…
![](../../users/profiles/147078.webp)
Eedoh
- 4,558
- 8
- 32
- 57
129
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
![](../../users/profiles/6687886.webp)
Stephen Alexander
- 1,277
- 2
- 6
- 6
69
votes
10 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
![](../../users/profiles/75500.webp)
Shimmy Weitzhandler
- 92,920
- 119
- 388
- 596
26
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…
![](../../users/profiles/838893.webp)
Santosh
- 1,869
- 10
- 36
- 54
24
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…
![](../../users/profiles/264989.webp)
Sharief Shaik
- 934
- 5
- 10
- 24
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…
![](../../users/profiles/2870700.webp)
hojjat reyhane
- 598
- 6
- 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
![](../../users/profiles/3355213.webp)
Vampire
- 308
- 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,…
![](../../users/profiles/934646.webp)
Shirish Herwade
- 10,601
- 18
- 66
- 105
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 |…
![](../../users/profiles/1369235.webp)
Himanshu Jansari
- 28,446
- 26
- 101
- 128
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…
![](../../users/profiles/1300627.webp)
holy
- 632
- 2
- 9
- 16
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…
![](../../users/profiles/162753.webp)
Rishi P
- 229
- 1
- 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
…
![](../../users/profiles/863041.webp)
Chirayu Shishodiya
- 546
- 1
- 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,…
![](../../users/profiles/2170785.webp)
LaDante Riley
- 481
- 4
- 14
- 23
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…
![](../../users/profiles/2040150.webp)
josele
- 57
- 1
- 9
3
votes
3 answers
nhibernate intercept select query
I'm looking at the nhibernate interceptor. It seems to be able to intercept save, update and delete queries but is there anyway I can intercept a select query.
The problem I have is that I automatically want to append some additional sql filters to…
![](../../users/profiles/192313.webp)
mat-mcloughlin
- 5,944
- 11
- 40
- 58