sql

MySQL Help: SELECT table2.id WHERE ... table1.date is largest

I have 2 tables, using an inner join to query them. SELECT COUNT(table2.id) FROM table2 INNER JOIN table1 ON table2.relazioneid = table1.id WHERE table1.date > ? AND table1.date < ? It counts the ids of entries on reports between 2 dates. Table 1 holds info on the reports (date, groupid etc), table2 holds the entries on the reports...

TSQL interview questions you ask..

Google search turns up some links to tsql questions. I was wondering what would SO experts would ask in an interview for TSQL. ...

store image in database or in a system file ?

Exact Duplicate: User Images: Database or filesystem storage? Exact Duplicate: Storing images in database: Yea or nay? Exact Duplicate: Should I store my images in the database or folders? Exact Duplicate: Would you store binary data in database or folders? Exact Duplicate: Store pictures as files or or the database for a web app? Exact ...

Looking for SQL query to display data from 2 tables that is not commone between the tables.

I have two tables that have the exact same structure. Table MasterList Acct_id(9) Name (25) Address (35) City(15) State(2) ZipCode(5) and Table NewMasterList Acct_id(9) Name (25) Address (35) City(15) State(2) ZipCode(5) I need a query that will display the Acct_ID and Name for all records from each table that are NOT in BOTH tables....

Oracle count statement problem

Hi, Hope someone can help with a problem I'm having with building a query in oracle. I'm a newbie to oracle, allthough i do have some little knowledge of sql - It's a cinema booking system scenario - and Im trying to get the sql below to output one line, which is a total of the tickets sold for a particular performance in a particular...

Asynchronous Triggers in SQL Server 2005/2008

I have triggers that manipulate and insert a lot of data into a Change tracking table for audit purposes on every insert, update and delete. This trigger does its job very well, in other words, we are able to log the desired oldvalues/newvalues as per the business requirements for every transaction. However in some cases where the sou...

How do I query a SQL database for a lot of results that don't have any common criteria?

I have a MS SQL DB with about 2,600 records (each one information on a computer.) I need to write a SELECT statement that selects about 400 of those records. What's the best way to do that when they don't have any common criteria? They're all just different random numbers so I can't use wildcards or anything like that. Will I just hav...

Does the way you write sql queries affect performance?

say i have a table Id int Region int Name nvarchar select * from table1 where region = 1 and name = 'test' select * from table1 where name = 'test' and region = 1 will there be a difference in performance? assume no indexes is it the same with LINQ? ...

Sql Optimization on advertising system

I am currently developing on an advertising system, which have been running just fine for a while now, apart from recently when our views per day have shot up from about 7k to 328k. Our server cannot take the pressure on this anymore - and knowing that I am not the best SQL guy around (hey, I can make it work, but not always in the best ...

Avoiding multiple sub-selects when grouping

I have a query that works like: select table_one.x, sum(table_one.y) (select foo from table_two where table_one.x = table_two.x) as item_description from table_one inner join table_two on table_one.x = table_two.x -- where table_2 row has various attributes group by table_one.x The grouping means I need a sub-select to access foo from...

Multiple update statements in one StoredProcedure

Hi I am wondering if it is possible to have multiple Update statements in a store procedure Something like this: Update Table1 set field1 = @new_value where id = @table1_id Update Table2 set field2 = @new_value where id = @table2_id Update Table3 set field3 = @new_value where id = @table3_id Right now I am executing them seperatel...

How do I create unique constraint that also allows nulls in sql server

The question is quite simple, as the title. Added a column to table I want a unique constraint , the column will insert guids, but to allow for existing data before column was added I need to allow for nulls in the check ...

returning query where field is null

I am trying to use the following query with my table: SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME, date_format(str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), '%d %m %Y' ) AS shortDate FROM AUCTIONS WHERE upper(ARTICLE_NAME) LIKE '%hardy%' and subcat = 'null' ORDER BY str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), article_n...

Return multiple counts with single PL SQL Query

I have the following two PL/SQL Oracle Queries that return a count: SELECT count(*) INTO counter_for_x FROM Table_Name WHERE Column_Name = 'X'; SELECT count(*) INTO counter_for_y FROM Table_Name WHERE Column_Name = 'Y'; Is it possible to write a single query that returns both the counts and populates the respective counter ...

multiple where clause in query failing

I am trying to select the following query from my table: SELECT ARTICLE_NO, USERNAME, ACCESSSTARTS, ARTICLE_NAME, date_format(str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), '%d %m %Y' ) AS shortDate FROM AUCTIONS WHERE SUBCAT = 'fake' and USERNAME = 'testuser' ORDER BY str_to_date(ACCESSSTARTS, '%d.%m.%Y %k:%i:%s'), article_no limit...

SQL Reader saying no values exist, query seems fine

I'm developing an ASP.NET application with VB, and using SQL Command and Connection in VB to grab the data for the page. I have both portions initialized as such: travelQuery.CommandText = "SELECT [StartLoc], [EndLoc],[TravelTime], [AvgSpeed], [Distance] FROM [TravelTimes] WHERE [TripNum] = '" + lblTrip.Text + "'" travelConnection.Conn...

dynamically naming a variable?

I have a table with various auctions, where each record has both a username and a category. More than likely, there will be multiple records with the same username and category. There are four different types of categories. I am wondering if it would be possible, given the prepared query below, to have the second bound parameter be the ...

Alternative SQL ways of looking up multiple items of known IDs?

Is there a better solution to the problem of looking up multiple known IDs in a table: SELECT * FROM some_table WHERE id='1001' OR id='2002' OR id='3003' OR ... I can have several hundreds of known items. Ideas? ...

Database schema changes needed yearly. Which Strategy should be used?

Hello, Every year our company holds a conference/stand where participants can show their products. We have a web-application which let the participants sign up for the conference. They can enter information such as the name of their company, billing information, and so on. It seems as if the requirements for what information the ...

SqlCeReplication Conflicts

Is there any connection between error "Failure to write to a message file" and conflicts on Publication side on SQL 2000 server? ...