sql

MS 2003 - SQL String inside of VB question - populate results into a form?

Okay so this is another question about a previous question I asked: http://stackoverflow.com/questions/1435802/rookie-sql-inside-of-vb-question-msaccess-2003 I am pretty new at this so I appreciate the help guys! So lets say I have a form and I want the SQL string in the VB to fill out a form based on parameters selected by the user o...

Help in a Join query

SELECT game_ratingstblx245v.game_id,avg( game_ratingstblx245v.rating ) as avg_rating, count(DISTINCT game_ratingstblx245v.userid) as count, game_data.name, game_data.id , avg(game_ratings.critic_rating),count(DISTINCT game_ratings.critic) as cr_count FROM game_data LEFT JOIN gam...

MySQL rejecting parameter

Ok, I'm going crazy on this one. MySQL is throwing a fit about this bit of SQL: INSERT INTO `test_table` ( `column1`, `column2` ) VALUES ( ?COURSEID, ?COURSENAME ) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COURSENAME )' at line 1 My d...

Split Ms Sql 2005 Table to two or more parts

I need to split an existing table in to two or more tables on Sql Server 2005. The table already has more than a thousand of rows. For eg current table has cols A, B, C, D, E plus an id column. An I need to add A, B, C rows to another table in another database and add D, E to another table in another database. I know that it is weird. ...

Generating tag cloud count given these 3 tables

I have these three table to store tags for photo albums. Here is the schema table 1: Albums Album_ID Album_Name table 2: AlbumTags Tag_ID Tag_Name table 3: AlbumTagBridge ID Tag_ID Album_ID What is the most efficient SQL to be able to come up with a result set that looks like this: Tag_Name | Count Tag 1 | 19 Tag 2 | ...

SQL question: Does the order of the WHERE clause make a difference?

From a performance standpoint, does the order of my SQL WHERE statements make a difference? For instance SELECT ... FROM ... WHERE a > 1 AND b < 2 Would that be any faster/slower than SELECT ... FROM ... WHERE b < 2 AND a > 1 Let's also assume that I know in advance that a > 1 will narrow the result set the most. Also, does it ma...

MSAccess query taking too long to execute.

Hi, I have Access 2003 with SQL backend. This query takes 10 minutes to execute and if I take out the Exists part it takes 10 sec. I can't put it in SQL as a passthrough query because I need it in a Access subreport. Any ideas how to improve execution time?? SELECT DailyLeaveLedger.dldEmployeeID, Sum(IIf([tolAnnualLeaveType]...

mysql trigger in administrator tools

I am using MySQL 5.1 Community Server. I have installed MySQL Administrator 1.2.12. The GUI Front-end is not showing anything to create and work with triggers. Why? ...

Hidden problems when modelling data using business objects

A common approach to data modelling is to use a data modelling tool (e.g. Erwin) to generate a schema, and then from the schema to generate business objects using an object relational mapper (ORM). Less common is the reverse process where the data modelling is done using business objects (e.g. POCO/POJO's), from which the schema is gene...

How to calculate interval between datetime in MySQL?

For example,how to calculate the interval between these two datetime: 2009-09-18 00:00:00 2009-10-17 00:00:00 EDIT I mean to get the interval in the format of year-month-day hour:min:seconds ...

how to insert data into table from stored proc, manual values together in a single insert statement

Can anyone tell me how to insert a record in a table in the following case: I have 2 tables: create table #temp1(c4 int, c5 int,c3 int) ...and: create table #temp2(c1 int, c2 int) create procedure sptemp as begin select c1,c2 from #temp2 end Now I want to insert records into #temp1 table using the procedure as: insert in...

MySql 'Order by Date' Question

Im pulling data from a MySql data table. I'm pulling from a row called 'PubDate' (meaning Published date). This format is in Date format, not DateTime. When I execute the query Select * from Articles order by pubDate ASC Its ordered by date as so: 1.09/18/09 2.09/18/09 3.09/19/09 4.09/20/09 If possible I would like to be able to...

Select Earliest Date and Time from List of Distinct User Sessions

I have a table of user access sessions which records website visitor activity: accessid, userid, date, time, url I'm trying to retrieve all distinct sessions for userid 1234, as well as the earliest date and time for each of those distinct sessions. SELECT DISTINCT accessid, date, time FROM accesslog WHERE userid = '1234' G...

how to keep combination of cells unique

i have table A and table B. I have a bridge table called tableC in table C i have: ID tableA_ID tableB_ID ID is the primary key. i also want to enforce the combination of tableA_ID and tableB_ID to be unique so there are no duplicate records. how do i enforce this? ...

A new sql connection for each query?

I'm writing a server application that's communication with a local sql server. Each client will need to read or write data to the database. Would it be better to have a thread safe class which will enqueue and executes the sql commands on a single sql connection? Or should I open a new connection for each command? Does it matter much f...

For each SQL query

We have a database that contains information about time booked to projects. We have a live record for a project, that holds the correct time information (imported from SAP once a week). We also have archived records showing the time information at a point in time, these are taken once a week, essentially they are snap shots. It is possi...

My SQL insert/update statement is too inefficient

I'm trying to write code for a batch import of lots of rows into the database. Currently I bulk copy the raw data (from a .csv file) into a staging table, so that it's all at the database side. That leaves me with a staging table full of rows that identify 'contacts'. These now need to be moved into other tables of the database. Next I...

how to create static cursor in db2?

I am facing a problem while creating a static cursor in DB2. This is the statement i used in my SP. DECLARE CURNAME SENSITIVE STATIC SCROLL CURSOR FOR SELECT COL1, COL2 FROM SCH.TABLENA ORDER BY COL1; on compilation it says : DB2 Database Error: ERROR [42601] [IBM][DB2/NT] SQL0104N An unexpected token "SEN...

Retrieving Two Values from a Stored Procedure

Can someone tell me how I can combine the two SQL statements that count the number of messages and number of unread messages? Its ineffecient two have two statements but I don't know what to search for to get the answer im looking for. Thanks in advance. CREATE PROCEDURE dbo.GetMessages ( @username nchar(12), @isCount bit, @messag...

In MySQL: fetching rows distinct by year

I have a MySQL table similar to this: | id | name | create_date | --------------------------- | 1 | foo | 2003-03-11 | | 2 | goo | 2003-04-27 | | 3 | woo | 2004-10-07 | | 4 | too | 2004-12-01 | | 5 | hoo | 2005-04-20 | | 6 | koo | 2006-01-12 | | 7 | boo | 2006-04-17 | | 8 | moo | 2006-08-19 | I want to fetch al...