Structured Query Language (SQL) is a language for querying databases. Questions should include code examples and table structure. This tag refers to the standard language, not for questions about a specific DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server). So if you think your ...

learn more… | top users | synonyms (4) | sql jobs

0
votes
0answers
7 views

jquery jtable check on sql inserts

This is probabaly a basic request im sure alot of people have implemented on JTABle (jtable.org). I basically want to do a check when adding a new record in the list action file and if the record ...
0
votes
1answer
14 views

SQL Server TOP(1) with distinct

I am trying to extract the first row I get after ordering the result by i_version_id. If I do not use TOP(2), my query works as expected ans returns all results sorted by i_version_id. But when I add ...
0
votes
0answers
10 views

How to import SQL data into db which already has same rows ids

I want to to combine 2 databases of business listings (table rows) into one database. All the listings (rows) are unique but the problem is that some of them have same database ids. So when try to ...
0
votes
0answers
9 views

Convert query to Eloquent query - Laravel

Please help me to convert the following query to Laravel Eloquent. I am struggling to covert sub-query and if statements. SELECT * FROM ( SELECT IF (msg.from_id = '2', msg.from_id, msg.to_id) ...
-1
votes
0answers
12 views

Setting selected item of ListBox in winforms throws array index out of bounds exception

I'm currently working on a project in winforms and run into a little trouble with setting the selected item of a populated ListBox. Basically, I have an SQL database which holds what I guess could be ...
0
votes
0answers
9 views

Questions on SQL Query Design based on filter expression

I have some questions on sql query design for SQL Server 2008. Lets say I have 2 tables, UserPeriod and Transactions. The columns in Period are PeriodID, StartDateTime, CloseDateTime and UserID. ...
0
votes
1answer
17 views

Oracle sql Inner join first record in right table

my question is this: I have two tables such as this: username | portname | symbol | shares ---------+----------+--------+------- phil | test | APL | 214 ...
0
votes
0answers
13 views

Querying between precise times

I'm trying to create a bash script that will query a SQL database exactly between 12AM to 11:59PM for the previous day. Currently I have: QUERY="SELECT * FROM CUSTOMER WHERE CUSTOMER.CREATE_DATE ...
1
vote
0answers
17 views

Multiple joins, show one value if it occurs more than once

Say I have 3 tables below: Table1 t1 id c1 c2 1 Jon Doe 2 James SMith 3 jolly rancher Table2 t2 id c1 1 addr_1 1 addr_2 2 addr_1 2 addr_2 3 addr_1 Table3 t3 id c1 ...
0
votes
0answers
2 views

Converting a SQL query to Active Record in Rails 4

Here are my two models class Comment < ActiveRecord::Base belongs_to :phone end class Phone < ActiveRecord::Base has_many :comments, :dependent => :destroy end Here is the schema for ...
0
votes
1answer
20 views

BIT shifting with AND operation in SQL select

I have a bit shifting to be done on NUMBER column in table. It is something like (NUMBER & MASK) >> 27 .. and i need to compare the result of this. Is this something that can be done through SQL ...
0
votes
1answer
20 views

How do you parse a custom formatted date time string into a datetime?

This is for Microsoft SQL Server I have an audit table with a timestamp represented as a string - timestamps are in multiple locale-specific representations (eg some are in mm/dd others are dd/mm) I ...
0
votes
0answers
25 views

“No Database Selected” when connecting to MySQL database with PDO

I am getting a strange, "No Database Selected" error when I try to insert rows into my database using PDO. Here is how I create the database: $pdo = new PDO("mysql:host=$dbhost", $dbusername, ...
0
votes
1answer
11 views

return multiple values and populate column in an array like manner

Please feel free to change the title accordingly Hi, I am using Postgres 9.3 on MacOSX. I am wondering how I can return multiple values (depending on certain criterion) and use them to populate a ...
0
votes
3answers
44 views

SQL ConnectionString not working

I am trying to connect to a local SQL DB and I got it working inside a console application but now when i try to do it on a windows service it doesn't work, I don't know what the problem is. The ...

15 30 50 per page