sql

Problem with a loop inside a PHP SQL statement

Here is my code, part of it is working flawlessly while the other isn't. <?php $query = "Select * from Query ORDER BY time DESC"; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { ?> <span class="hotspot" onmouseover="tooltip.show('<center><b><?php echo $row['name'] ?></b></center>');" onmouseout="tooltip.hide...

sqlite diff-script generator

Given two sqlite databases A and B, is there a tool that can generate SQL commands that will convert A to B (or vice versa)? This must included insertions, deletions, and updates - and maybe also table alterations (though that's not important to me). Possibly this tool is not even sqlite-specific. ...

Make a fake schedule if it doesn't exist in db

I want to pull all the rows from a database for a month and if there are any rows in the beginning or in the end that are missing then I want to create fake rows, so every day there is a schedule that one has to follow. How can I detect missing rows or how can I solve this issue? ...

Updating table with the earliest date from another table.

IR.DOC_ID D.DOC_ID D.WORK_ID I.WORK_ID I.DATE_SUB IR.DATE_SUB 1812450 1812450 8521 8521 11-AUG-09 1812301 1812301 8521 8521 11-AUG-09 1812400 1812400 8521 8521 11-AUG-09 1814250 1814250 8521 8521 12-AUG-09 1822300 1822300 8521 8521 18-AUG-09 18143...

EORROR : Near Keyword SELECT on 6 line

set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[FlowClientGetCatWeb] (@ID_Izmerit Integer, @ID_User Integer, @APP bit) AS SELECT Name, (CAST(ID_ListGroupParIzm AS nvarchar(10))+'_'+CAST(Point AS nvarchar(10))) AS GroupPoint FROM SELECT ID_ListGroupParIzm, Name, Point FROM FlowClientGetCat(@ID_Izmerit,@ID_User,@...

Search database using LIKE and wildcards

I have four search fields that are used to search a database for book id:s and then echos out the result. Depending on wich field you choose to search from the sql query builds up as you can see in the code below. The title and isbn field are working fine but when I try to use the author or category field nothing gets returned. The relev...

Paging in Advantage Database

Hello, i'm creating a web app that's running on an Advantage Database server, not my personal weapon of choice but that's what the company uses. I have a couple of big lists that the end-users need to be able to view however i can't seem to find a way to page through the results in SQL. Is there something like LIMIT / OFFSET for Adva...

How to prevent crashes when parameter is null

i am inserting the value of dynamic controls into the db like so; Dim ae1 As DropDownList = FindControl("AreasExpertise1") If (ae1 IsNot Nothing) Then x.Parameters.AddWithValue("@areasexpertise1", ae1.SelectedValue) End If then in my query i have parameters like so; INSERT INTO [foo] ([etc], [etc], [etc], ...

How can I get the Primary Key id of a file I just INSERTED?

Earlier today I asked this question which arose from A- My poor planning and B- My complete disregard for the practice of normalizing databases. I spent the last 8 hours reading about normalizing databases and the finer points of JOIN and worked my way through the SQLZoo.com tutorials. I am enlightened. I understand the purpose of data...

Painfully Slow DB2 Query

This query is PAINFULLY slow and our team cannot figure out why. We've tried creating views, but it still extremely slow. Any thoughts? SELECT CI . CWARCASNBR AS CASENUMBER , CI . CT1FYA AS COURTAGENCYCODE , CI . CIPTYSQNBR AS PARTYSEQNBR , CI . CIRCDTYPE AS CASETYPECODE , CP . NMELASTBUS AS LASTNAME , CP...

MySQL JOIN ON with WHERE

I have 2 tables and want to query all the album data joined with the artist artists: artist_id | name albums: album_id | artist_id | songs This gives me only the first row SELECT * FROM albums JOIN artists ON artists.artist_id = albums.artist_id I want to specify an album id SELECT * FROM albums WHERE album_id = 101 JOIN arti...

openning sql connection from iis7?

i created an asp.net website with visual studio 2008 sp1 and in the code i use sql connection to reach a data base in my sql server 2008. it all wiorks great but then i wanted to deploy the website in iis7 (windows 7) which was hell to discover how to do it- ( i added a virtual directory and converted it to an application and only then ...

Open new SQL Server connection in PHP

I have an open SQL Server connection and need to open and close another while maintaining the first connection. I CANNOT hold onto the resource ID for the original. Connection A (may or may not be open) Open connection B Perform a few queries using connection B Close connection B Continue working with connection A ...

SQL Split like Select

I have a field that contains values like: A12345 AB456 1234 AA 45 Is there anyway to Select these in two separate columns as Numbers and Letters. Thanks in advance ...

mySQL: Updating multiple values in a record with a SELECT from another table

Trying to sort out the correct syntax for this UPDATE: UPDATE `foo` SET (`x`, `y`, `z`) = (SELECT `x`, `y`, `z` FROM `bar` WHERE `id` = 'baz'); In the actual query, there are 165 columns so I very much do not want to have to do x = x for each column. The columns are not a p...

3 Table Join in MySQL

Hello! Say I have 3 tables. Table1 contains client_id and client_name. Table2 contains client_id, client_catid_1, and client_catid_2. These to tables are joined based on the, client_id. Now the third table, contains category_id and category_name. How can join the third table based on the category id's and get the category_name? example...

Computing different sums depending on the value of one column

In psuedo-code, this is bascially what I would like to do: select if a1 >= 0 and a1 <= 2 a2 + a7 + a8 as sum else a2 + a8 as sum from table_name ; (The column names, etc. are just for illustration.) In English: I need to sum different columns for each of a few thousand records. I'd like to do the sum in SQL,...

Microsoft Reporting Services. Should I use webservices as a datasource?

I have a dilemma. Here is my set-up: ASP.NET/NET 3.5 web application build using standards(DB layers, BL layers, etc...) I need to generate some reports. Standard way of doing that is to have reporting service query database directly OR I can have reporting services query web services(which I will create). I like web services approach ...

Multi database schema export

Hello, I'm writing a project that will make use of mySQL or Derby (it must work in both situations). To solve this I'm using Hibernate and it works nicely, but for a situation: I've a couple of tables that contain cities and towns, with data related so that if i know the town I can join and get the county, state and zip code. These table...

How do I join a one-to-many table with results only appended to the smaller table?

Basically I have a one-to-many table. I want to append the columns of the larger table to the result set of the smaller table. I will end up with a result set the same size of the smaller table, but again, with the relevant information from the many sided table. One catch: the many sided table doesn't have a primary key defined, althoug...