Questions tagged [sql]

Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample data, and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used. If your question relates solely to a specific DBMS (uses specific extensions/features), use that DBMS's tag instead. Answers to questions tagged with SQL should use ISO/IEC standard SQL.

Filter by
Sorted by
Tagged with
-10 votes
1 answer
137 views

Query for a string containing a particular character [closed]

Which SQL query will collect all the persons whose name include character“k”? The table name is “person_info” and the column for person name is ”name”.
Umais Gillani's user avatar
-10 votes
2 answers
125 views

Change decimal to integer in SQL [closed]

I need to round off decimal value to integer in SQL Eg : 748.444645 to 749
Logesh's user avatar
  • 9
-10 votes
1 answer
107 views

How can I get the index number of any column in an SQL database?

SQL: Select ROW_NUMBER() OVER(Password) From Student
Satyanand bhardwaj's user avatar
-10 votes
1 answer
66 views

join in table for multiple column [closed]

i have 2 tables [ table1, table2 ] Table 1 +----+------------+ | id | name | +--+--------------+ | 2 | Film | | 1 | Music | | 3 | OTHER | | 5 | Sports | | 4 | TV ...
Prade jo's user avatar
-10 votes
2 answers
168 views

Convert a string to date in SQL Server

I am facing a problem where I need to convert a string to date like 11 years 10 months 12 days to a date in SQL Server. Please help any help would be appreciated.
Yash Shukla's user avatar
-10 votes
3 answers
95 views

Need to combine two columns in a table [closed]

I need to combine two column in a table using alias name select firstname as fn, lastname as ln, userid, fn + '' + ln as fullname from users Error is Invalid column name ...
Bhargavi's user avatar
  • 851
-10 votes
2 answers
4k views

Where clause with fetch next row

How to user where clause with fetch next in sql query. My query ends like: 10 ROWS FETCH NEXT 5 ROWS ONLY WHERE table.FullName LIKE '%name%' Am getting error in where clause. error message ...
Youv's user avatar
  • 75
-10 votes
1 answer
58 views

a query in sql server [closed]

I have a table with this field in sql server : user_id , seller_id , cat_id , brand_id , action_type action_type values is 0 , 1 , 2 , 3 I want a query that can show me per "user_id and seller id " ...
mskhfigsh mskhfigsh's user avatar
-10 votes
1 answer
56 views

Concatenate as A and choose either A or B according to their FKs [closed]

I have three tables: IDcontacts | FirstName | LastName ---------------------------------- 1 | Walt | Ne IDcompany | CompanyName ------------------------ 1 | Universe IDowner |...
JohnAPaul's user avatar
-10 votes
1 answer
69 views

How to use math in mysql

I am creating database view but How can I calculate ant put that column like picture. EDIT: SELECT orders.id AS order_id, order_products.qty AS p_count, order_products.unit_price AS ...
Vepa Mirzayev's user avatar
-10 votes
1 answer
143 views

VBScript to return dates older than today by one day only

I have the below SQL query that return dates, I need to evaluate the dates and result only dates older than today by one day only. SELECT Address, max(Date+ ' ' + time)as last_Trans_time FROM ...
Amir's user avatar
  • 11
-10 votes
3 answers
2k views

How to select last row inserted [duplicate]

I inserted values into an SQL table that has an auto increment primary key and I want to get the Pk value that the last insert has it. How do I do that?
shiroi's user avatar
  • 1
-10 votes
1 answer
68 views

how to replace values in sql

I WANT LIKE THIS IN THE ATTACHMENT thanks
user7338184's user avatar
-10 votes
4 answers
130 views

How to get result from two tables without a join [closed]

..first table contain id,name,age.. 2nd table contain id , salary ... how to combine them without a join?
Vinoth Yesuraj's user avatar
-10 votes
2 answers
154 views

i am new to sql .Not Getting query result . Runs fine with no error

private void button1_Click(object sender, EventArgs e) { DataTable DataTab = new DataTable(); DaSql = new SqlDataAdapter("SELECT * FROM Student where Gender = '" + textBox1.Text + "' ", conSql)...
Ali Ahsan Noon's user avatar
-10 votes
2 answers
156 views

Count SQL Query [closed]

Hello Have a table like below and I am trying to count the number of Linux and Windows servers I have per Management Address How could one do that:
user2464795's user avatar
-10 votes
3 answers
1k views

Execute query using C# [closed]

I am trying to execute some SQL code, connected directly to my database, but I don't know how to execute the query. SqlConnection connect = new SqlConnection("DATABASE"); SqlConnection myConnection ...
Nevesito's user avatar
  • 125
-10 votes
1 answer
119 views

Search query using php and mysql [closed]

Need help on how to filter search results in the search form using PHP and Mysql. The form contains six fields Product is textbox, Category is drop down select item, Business in text box user enters ...
Harishankar's user avatar
-10 votes
1 answer
1k views

Search box to work like google search [closed]

I have a sql query that should return results for user text (Like free text search)which can be a single character or word or combination of words. For example if I have column named "subject" and ...
osaka's user avatar
  • 328
-11 votes
1 answer
2k views

Counting number of zeros in MySQL [closed]

I have the following data: htno sub marks credits 1 a 15 0 1 b 10 0 1 c 25 ...
Aryan Manoj Raj's user avatar
-11 votes
2 answers
2k views

Converting datetime variable format

I need help in converting a DateTime variable with format mmm dd yyyy to a Datetime variable with format yyyy-mm-dd
jai's user avatar
  • 1
-11 votes
1 answer
136 views

what`s wrong with this code? [closed]

I write this but it doesnt work, can`t find the error. this server side code get the the variable $cpu & $display and use it in select from the data base. when the variable is not important "*" ...
johnycena's user avatar
-11 votes
1 answer
140 views

How to improve performance of this query [closed]

select * from dbo.tble select * from dbo.tble
Alexo's user avatar
  • 19
-11 votes
1 answer
68 views

Sql query guide me [closed]

SELECT ( SELECT COUNT(*) FROM JLOAN_HI_CSVDATA WHERE jloan_hi_csvdata.INSERTEDDATE >= TO_DATE('15-02-15', 'DD/MM/YY') AND jloan_hi_csvdata.INSERTEDDATE <= TO_DATE('19-02-...
Nitin Kaushik's user avatar
-11 votes
1 answer
73 views

How to debug in sql(Oracle) [closed]

I am writing a long SQL query and I'm getting incorrect output fields. How do I debug this query?
user2639663's user avatar
-11 votes
2 answers
3k views

How to write attribute name on two lines in a SQL Query

How can I write heading column names in two lines in a SQL query? I want it to display like this: columnname
Durga Prasad's user avatar
-11 votes
1 answer
92 views

combine multiple rows into one in sql

I have a table through which I am getting some data now given below col1 col2 col3 col4 col5 col6 col7 ------------------------------------------------------------ SA106141 ABC ...
hamesh anand's user avatar
-11 votes
1 answer
133 views

SQL db and Combobox [closed]

code syntax that pulls database names, from the sql server and populate them into a combox and populate another combox with table names of that selected database name private void Onload(object ...
Penelope Penn MaC'bellë's user avatar
-11 votes
2 answers
120 views

Need this Query SQL Server

I have a following set of data. http://i57.tinypic.com/sn2y6a.jpg And i'm trying hard to sort this data as below. So, Below is the output data. http://i58.tinypic.com/xptth2.jpg 1)There is a new ...
SQLquery's user avatar
-12 votes
1 answer
152 views

SQL Server : how to sum? [closed]

How can I sum to get the total value using SQL Server? Thank you.
eikaz's user avatar
  • 401
-12 votes
2 answers
1k views

MySQL column wise category counting [closed]

I have a table like: id name center1 center2 cnter3 1 abc baroda bhopal chennai 2 pqr amhedabad Surat kolkata 3 nml bhopal chennai Surat 4 fts baroda Surat ...
user1660799's user avatar
-12 votes
1 answer
3k views

How can I drop a view in Oracle? [closed]

I have a view defined in my Oracle database and I would like to drop it. How can I drop a view?
Yasmine Hoseok's user avatar
-12 votes
4 answers
7k views

SQL (employees with same birthdate)

i have this table: name dob Avash 1991-07-23 Bipin 1990-03-25 Bijay 1990-03-25 How do I fetch a list of employees who have the same dob?
altubeish's user avatar
-12 votes
1 answer
1k views

How to find list of tables used in stored procedure without "With (nolock)" words [closed]

I have large table data and each table need to be end with the statement (nolock) at the end , please help me to find in all stored procedure. Example: if a store-procedure used two tables a and b ...
Rahul Hera's user avatar
-12 votes
3 answers
99 views

How to select data from the following table?

With table data as: How to obtain the result as:
Siby Sunny's user avatar
-12 votes
1 answer
114 views

What's the problems on this sql command code? [closed]

string str = string.Format("SELECT User1.NAME,User1.PORT,User1.IP,File1.SIZE FROM ((SELECT UID,FID FROM [User_File] WHERE FID= {0}) AS a) ,[User1],[File1] WHERE a.UID= User1.UID AND a.FID=File1.FID", ...
gal kogeman's user avatar
-12 votes
2 answers
69 views

How can I quickly solve this query? [closed]

I have one table which contains 3 fields namely code, name, rperson. It has following data: code name rperson 100 anil 100 101 babu 100 102 sajad 100 103 Rajesh 102 104 roy 102 ...
aparna's user avatar
  • 1
-12 votes
2 answers
421 views

How do I join on multiple columns in SQL Server and include columns in one table that aren't present in other tables?

I have two tables with a similar schema as Example Table 1 and Example Table 2. Both tables have columns that identify the data which are in both tables. Columns A and B are in both tables. Table 1: ...
RMichalowski's user avatar
-13 votes
1 answer
323 views

I want to create my own tables in it and work on them [closed]

I installed Oracle SQL developer on my personal computer. I want to create my own tables in it and work on them. But, when I try to make the basic connection, it gives an error below i want to ...
Raza Khan's user avatar
-13 votes
1 answer
2k views

Can we select the table data without using select statement [closed]

Is it possible to select the data using indexes without using select statement...
krishnakishore's user avatar
-13 votes
2 answers
380 views

How we can insert data without using insert clause? [closed]

How we can insert data without using insert clause ??
Lovedeep Singh's user avatar
-13 votes
1 answer
165 views

Php Filter array

I need a simple example of php filter array. This function is new for me so please I can't understand complex program of it. I want to store filtered data to the database from a simple form where ...
Waleed Khan's user avatar
-14 votes
1 answer
854 views

Creating a table with duplicate primary keys [closed]

How can I create a Table in SQL Server that has a Primary Key and a Foreign Key, but the Primary Key data should be repeated? For example: PK FK 1 100 2 100 1 200 3 100 4 200 4 ...
bhanu prakash's user avatar
-14 votes
1 answer
146 views

Python sql order by

My code: sql = """ SELECT seq_no, step_name, date FROM tra..trav TR INNER JOIN trav..trav_step TS ON TR.tr_OID = TS.tr_OI ...
Swathi's user avatar
  • 9
-14 votes
3 answers
3k views

there is already an object named '' in the database

This is my code: CREATE TABLE supplier -- creating table supplier ( supplierID INT NOT NULL IDENTITY, supplierName VARCHAR(30) NOT NULL, suppplierNo VARCHAR(10) NOT NULL, supplierEmail ...
Luan Lourens's user avatar
-15 votes
3 answers
2k views

Subquery returned more than one value error

I am using the following query, but it is throwing an error. It is working fine for some scenarios, depending on the id, but not for all. Subquery returned more than 1 value. This is not permitted ...
Ubaid Ashraf's user avatar
-16 votes
1 answer
158 views

Insert using stored procedure

I want to insert a record into multiple tables at single time using a stored procedure. But if it already exists, that record could not be inserted. How can it? I need help. I have link between the ...
Rakesh Jamal's user avatar
-18 votes
1 answer
167 views

Subquery returned more than 1 value. wrong if statement [closed]

if condition equal to true then I would like multiplication (od.price * od.kilo), and then bring the other fields else I would like multiplication(od.quant * od.price) and then bring the other ...
Mohamed Hmmam's user avatar
-20 votes
3 answers
246 views

SQL duplicated rows selection without using "having"

I have this type of table: A.code A.name 1. X 2. Y 3. X 4. Z 5. Y And i need to write a query that gives me all ...
E25's user avatar
  • 11
-26 votes
3 answers
2k views

Can storing wildcard strings in a column (to be used with LIKE operator) cause unexpected query results or security issues?

Could storing wildcard strings in a table's column (to be used as the second operand of the LIKE operator in queries) cause any non-obvious behavior? I'm wondering especially about the possibility of ...
ruohola's user avatar
  • 22.9k