sql

PHP & MySQL - How to delete a users records from two tables.

Hello I'm new to PHP & MySQL and I was wondering how can I delete all of user_id 3 records from these two tables below using PHP & MySQL? My MySQL tables CREATE TABLE ls ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, skill VARCHAR(255) DEFAULT NULL, experience VARCHAR(22) DEFAULT NULL, self_grade VARCHAR(10) DEFAULT NULL, date_created DAT...

What logic to use to rollup/merge multiple person entities as the same? (tight, but fuzzy enough to broaden matches)

I have multiple instances of people entities which are often times the same person. Where the address First-Last is the same at the same address, it's a no-brainer to merge/rollup them. However, due to data entry inconsistencies, there must be a way to deviate a bit from the exactness. I think the credit card industry does this a little...

How to get sql query result into a text file with a specific file name like name_dd-mm-yyyy.txt.

Hello Everyone, Please suggest me how to get sql query result into a text file with a specific file name with current date like name_dd-mm-yyyy.txt.I want do this automatically using a job or Stored Procedure. ...

ibatis: improve insert performace

Hi I am using ibatis for my sql insert stmt. In my code i am parsing files line by line from a folder. Each line that matches criteria, need to be inserted into database. Total number of insert in a single run of program can be any where along 200k. SqlSession sess = null; this.sess = sf.openSession(ExecutorType.BATCH, fals...

Why does the parameterized version of this query run slower than a non-parameterized version?

Sample Query: CREATE PROCEDURE dbo.Test (@p varchar(10)) AS DECLARE @param varchar(10) SET @param = @p + '%' SELECT * FROM table1 t1 INNER JOIN table2 t2 on t1.id = tr.id WHERE t2.desc LIKE @param I've a query which is similar to one above and when i use this in stored procedure it runs indefinitely without giving any output. But if ...

How do I split a sentence in SQL Server 2005

I have a column named Address in a table. I have values such as 12-15 Hardley Street 2A-C Hardley Street A-2c Hardley Street A-B Hardley Street I am required to keep the hyphen(-) intact in the first three rows. i.e. If there is a number in the word that contains the hyphen(-), I should keep it, else I should replace with...

How I can prevent SQL injection in zend

Possible Duplicate: Zend Db avoiding sql injections I use following code $this->getDb()->fetchRow($sql, $params); Is it free from sql injection? Please guide me. How i can make it free from sql injection. ...

MySql syntax question

Why does this work perfectly: SET @columnQuery = 'INSERT INTO ColumnNames SELECT ORDINAL_POSITION, COLUMN_NAME FROM information_schema.columns WHERE TABLE_NAME=''residents'' ORDER BY ORDINAL_POSITION;'; PREPARE STMT FROM @columnQuery; EXECUTE STMT; but this does not: DECLARE TableName VARCHAR(50); SET @TableName = 'residents'; SET ...

How can I send data from Yahoo quotes to MySQL with Perl?

After I download data from Yahoo and Google finance, how I do use a Perl script to send these to MySQL database automatically? ...

working with images as a database table column

Hi, Ii have a database (sql server 2008) and I am working with c# in visual studio 2010. I want to establish a connection with my db. I have written a code for that as follows: SqlConnection mySqlConnection = new SqlConnection ("Data Source=servername\\SQL2008; Initial Catalog=MyData;UID=MyID;PWD=mypassword;"); SqlCommand...

SQL CASE statements on Informix - Can you set more than one field in the END section of a case block?

Using IBM Informix Dynamic Server Version 10.00.FC9 I'm looking to set multiple field values with one CASE block. Is this possible? Do I have to re-evaluate the same conditions for each field set? I was thinking of something along these lines: SELECT CASE WHEN p.id = 9238 THEN ('string',3) END (varchar_field, int_field); Where the...

mysql is array in multiple columns

I have a string in the form $string = 'London,Paris,Birmingham' and I want to search multiple columns for occurences of these values. For example WHERE events.name, events.cities, events.counties IN (".($string).") Can someone recommend me a simple and short way of doing something like this. ...

Evaluate sequential pairs of rows in SQLite

I have data in an SQLite table that looks like this: user_id event_date ---------- ---------- 1000001 2008-01-01 1000001 2008-03-13 1000001 2008-07-04 1000002 2007-01-06 1000002 2008-01-01 1000002 2009-06-01 1000002 2010-12-11 For each of the user_ids I would like to select the largest time gap between...

PostgreSQL: How to constrain more than just existence on foreign key?

In PostgreSQL, what's the simplest way to enforce more than just existence on a foreign key? For example, given the following tables: create table "bar" ( bar_id serial primary key, status boolean not null ) create table "foo" ( foo_id serial primary key, bar_id integer references "bar" ) How could f...

get list of numbers in between two columns

I have a table1(startnumber, endnumber) in oracle; Now I need to select all the numbers lies in between startnumber and endnumber from table1 data eg. table1 startnumber endnumber 10 15 18 22 34 50 Now I need the result set as: 10,11,12,13,14,15,18,19,20,21,22,...

Exclude results from join where duplicate keys match occur

I work with data that comes from multiple sources that I have no control over. These sources tend to have duplicates in the "key" values. I need to keep any of these duplicate values form matching in a join. Using the following data T1 | ID | FirstKey | SecondKey | ThirdKey | AdditionalColumns | +----+----------+-----------+-------...

refresh html page when a new sql entry has been inputted

So I have an external script that will sometimes input something into a sql database throughout the day (usually about 3 times a day, but could potentially update ever minute) I need to find a way to make the html page (that displays the sql entries) refresh automatically when there is a new entry that's added. Any suggestions for PHP an...

Excluding matches on JOIN fields that are NULL

If you do a join that looks like this SELECT T1.KeyField1, T1.KeyField2, T2.Field3 FROM T1 JOIN T2 ON T1.KeyField1 = T2.KeyField1 AND T1.KeyField2 = T2.KeyField2 Is there a way to not allow NULLS to match similar to the results this query would return SELECT T1.KeyField1, T1.KeyField2, T2.Field3 FROM T1 JOIN T2 ON T1.KeyField1 = T2....

SQL Server 2005 backups for previous 5 days on disk?

My goal is simple. I want to have SQL Server keep a nightly backup of a DB for a rolling 5 days. So each night at some time I want a new DB backup made and one deleted such that I have a rolling 5 days on disk. I am trying to get a maintenance plan set up to handle this work and have the saving of the file done (I think). I have the ba...

Why is CakePHP duplicating my queries? (this is not the same "too many queries" problem that is usually asked)

I've defined these relationships in my models: Lead hasMany Job Job HABTM Employee Job HABTM Truck I'm trying to do a find('all') from my Truck model, and limit the results to: All Trucks, all jobs associated with those trucks that have a certain pickup date, the employees assigned to those jobs, and the lead associated with the jo...