Questions tagged [select-query]

176 questions
1
vote
4 answers

SQL select query join

Below are my MYSQL tables. I am not able to figure out what a MySQl query looks like that selects only one row from parent for each month (by latest date in a month) and its consequent child rows. So in the given example it should return rows from…
Kaizar Laxmidhar
  • 859
  • 1
  • 17
  • 38
1
vote
1 answer

Oracle Sql query to return the column result in single row

I have below select query: select distinct(e.ENGINE_ID), e.ENGINE_NAME, os.OBJECT_STATUS, br.NAME, env.NAME from ENGINE e, RATOR_MONITORING.OBJECT_STATUS os, BRAND_ENGINE be, ENVIRONMENT env, BRAND…
Andrew
  • 3,632
  • 24
  • 64
  • 113
1
vote
2 answers

SQL Select error and OUTPUT

I need to query a database for some information and then store it into a .csv file in case the dispatch system goes down. I'm running into some issues with the select query as well as the output statement. Here is what I have: SELECT cmpy, veh,…
William Hodges
  • 661
  • 10
  • 24
1
vote
1 answer

How to create a select query calculating 'age' by user's date of birth?

I want to make a select query to search seeking person between min and max ages. This is how search values comes from my search form. Array ( [iam] => Man [seeking] => Woman [age_min] => 18 [age_max] => 19 [country_id] =>…
MCC
  • 47
  • 1
  • 6
1
vote
2 answers

Syntax error in Microsoft Access SQL Select query in VBA procedure

I am having following VBA Code that has been giving a syntax error. Can someone please help me figure out what is causing the error? Private Sub Command11_Click() Dim EndingDate As Date 'Getting ending date from Label named endDate …
ms8
  • 417
  • 2
  • 13
1
vote
0 answers

Selecting data based on a specific XML tag of an XML which is stored in one of the column (of data type text) of a table in Sybase database

The table in Sybase database has a column which is of type 'text' say 'myXML'. This column stores entire XML. I need to retrieve data based on specific value stored in the XML. For exmaple, in the below table I need to get all the rows which has the…
1
vote
1 answer

How to execute parameterized select query on .mdf database and display a column value?

I have a SQL Server database file MsUser.mdf with a table MsAccount that has 5 columns: userID accountID accountName accountBalance imageLocation I need to find the accountBalance where accountID = combobox that being selected, and show it…
1
vote
2 answers

select query from one table to check same value exist in column, mysql select query

I have one table and i want to check that for one column all value are same. following is the entry in my table. two column rid,value (1,1) (1,1) (2,1) (2,0) (2,0) (3,0) (3,0) (3,0) I want query which gives me rid 1 because all of its value is 1.…
Satish
  • 1,012
  • 2
  • 15
  • 32
1
vote
1 answer

MySQL Group by and Having clause issue

I'm trying to get the correct records but for reason I've some issue in Having clause I guess, can anyone please help me out? CASE 1: Trying to select rows where order_id = 1 (New Order) but should not have more than 1 record with the same order…
Nadeem
  • 419
  • 4
  • 13
1
vote
3 answers

SQL query with additional 'nearest' row

Consider the following table structure: id speed 1 100 2 200 3 300 4 400 5 500 Consider the following query: "SELECT * FROM records WHERE speed >= 300" - this will return the rows #3, 4, 5. Is there a way to modify this query so…
Zaur Nasibov
  • 22,280
  • 12
  • 56
  • 83
1
vote
2 answers

Select query with max date

I have this query SQL query: selecting by branch and machine code, order by branch and date SELECT mb.machine_id AS 'MachineId', MAX(mb.date) AS 'Date', mi.branch_id AS 'BranchId', b.branch AS 'Branch', b.branch_code AS…
naru
  • 129
  • 4
  • 20
1
vote
2 answers

Select query with doctrine

I was trying to create a select query with doctrine but it didn't work. I have three tables, Product(ID, Name), Client(ID, Name), Orders(product, client). I need to select and show all the orders made by a client, and also the product name. How can…
Neph1s
  • 23
  • 1
  • 4
1
vote
4 answers

MYSQL query to exclude records in specific condition

Hey I have the following MYSQL DB structure for 3 tables with many to many relation. Many users can have many cars and cars can be for many users as showing below: Users ID | Name --------- 100|John 101|Smith Cars ID |…
Hadi.M
  • 544
  • 1
  • 6
  • 19
1
vote
1 answer

sql query that would return a table, and count other tables relevant to the results of the first

I'm trying to write a forum for a school project, and I'm still struggling with some queries. So, basically I have the following tables: forums (forum_id,forum_title,forum_description) topics (topic_id,forum_id(the forum that it belongs to),…
William Northern
  • 403
  • 2
  • 5
  • 12
1
vote
4 answers

Return sql results as a single string

I have the following query which returns more than 1 result (max is about 10rows not more!), how can I return all results as a single string? SELECT DISTINCT(e.Username) FROM TblLeaveEmployee l JOIN TblLeaveApprovalsBy a on l.EmployeeId =…
rikket
  • 2,357
  • 7
  • 46
  • 74