sql

Count Instances in Table1 AND link to Table2

Please refer to this background question. After constructing this COUNT, how would I then link each of these 'Prices' to, for instance, a column called 'Genre' in TableTwo? e.g. Table1: Prices, ID Table2: Genre, ID Example output: PRICES, COUNT, Genre -------------------- 13.99, 2, Horror 52.00, 3, Comedy 1.99, 1, Rom...

Php Numrows problem

Hello! I use query string to access my pages. I try to make if anyone type unknown query string manually, then redirect to somewhere.. For example: Url: test.php?m=1 (this is a valid url) test.php?m=1324234 (this is not a valid url ) test.php?m=1asdaa (this is not a valid url ) include("config/database.inc"); $qm=$...

create an xml file using a shell script

I have a table with two columns column_1 column_1 12345 12345 73255 73255 71377 71377 Now i want to create an xml like <header> <value>12345</value> <value>73255</value> <value>71377</value> <footer> basically i need to use a select query and put any one of the fields into the values of xml. could you please suggest h...

Smart device connect with sql server

I want to connect to sql server with samart device application but error is there . sql execption so please help me ...

How to make MySQL log down all queries that didn't use index?

I'm starting to do the job of sql optimization, but I don't know how to configure MySQL properly to make it log slow queries. ...

SQL update one table from another table.

Here’s a simplified version of my problem Table 1 Key1, lastdate, lasttranstype Table2 Table1key1, trandate, trantype I want an SQL statement to update lastdate and lasttransdate on table1 for each record in that table using the matching record in Table2 with the latest date My DB is progress. Is this possible (I can of course write...

Auto-increment the primary key without setting the identity

I am using the following syntax to insert new records (I don't want to have duplicate keys): insert into tbl(key) values select max(key)+1 from tbl Someone says it will have concurrency problem. Is that right? SELECT -> LOCK table -> INSERT or LOCK table -> SELECT -> INSERT Which one of the above is correct? ...

Data Access Application Block (DAAB) and the SQL IN keyword (multiple criteria)

Hello, I am using the Patterns and Practices Data Access Application Block and I want to be able to perform a SELECT using multiple criteria like you can do in SQL using the IN keyword. Such as: SELECT * FROM SomeTable WHERE PrimaryKey IN (@keys) How can I pass in the @keys values? I do not want to have to dynamically build my SQL. ...

Need Linq translation for the following SQL Query

select colId, colTaskType, MaxID from tblTaskType join ( select tblCheckList.colTaskTypeID, max(colItemNumber) MaxID from tblCheckList group by colTaskTypeID ) x on coltaskTypeID = tblTaskType.colID ...

MySQL group by intervals in a date range

I am going to be graphing netflow data stored in a MySQL database, and I need an efficient way to get the relevant data points. They records are stored with the date as an int for seconds since epoch. I Would like to be able to something like: Select SUM(bytes) from table where stime > x and stime < Y group by (10 second intervals) Is ...

SQL query logging for SQLite?

I need to log queries from a number of applications that use SQLite. Introducing logging to the applications would in this case not be a feasible solution in practice. So how can I enable query logging in SQLite itself? ...

Find a Windows-1252 char in mysql column

There's a row that I believe contains a Windows-1252 smart-quote char in a particular column that is messing up a user of this table. How can I select any row that contains any Windows-1252 punctuation in this column? AND it would be really cool if I had a way of converting these values if I redefine the column as being utf8 (it's curre...

liquibase - Cant get sample to work

Hi, Im trying to get to run a very simple example in liquibase 1.9.5 (see at the end). When I run liquibase --changeLogFile=test_sample.xml update I get this error message. Migration Failed: ORA-03115: unsupported network datatype or representation Im using oracle 10g XE 10.2.0.1. As I understand (and googled), this is an...

Problem with quotes and paramterized SQL query

I have a very simple search form, that takes in a term from GET_, and then incorporates this into an SQL query. I am trying to use this string from GET in a paramterized query, like so: $searchString = '%' . $searchString . '%'; $recordsQuery = "SELECT username, firstname, lastname FROM $table WHERE lastname = $searchString" . $max; ...

SQL Archive Script

Hello, I'm trying to archive records from a table in a database to an identical table in an archive database. I need to be able to do an insert for all records with a date greater than three years ago, and then delete those rows. However, this table has millions of records which are live, so I want to run this in a loop of roughly 100 ...

How to optimize this query?

Query: select id, title from posts where id in (23,24,60,19,21,32,43,49,9,11,17,34,37,39,46,5 2,55) Explain plan: mysql> explain select id,title from posts where id in (23,24,60,19,21,32,43,49,9,11,17,34,37,39,46,5 2,55); +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | id...

SQL Server : SUM() of multiple rows including where clauses.

I have a table that looks something like the following : PropertyID Amount Type EndDate -------------------------------------------- 1 100 RENT null 1 50 WATER null 1 60 ELEC null 1 10 ...

Mysql create database with new database location

Few months ago I have asked a question regarding how to change database location at runtime - I didn't get any solution for this problem yet. I am needing to create more than 32,000 databases in MySQL. The default data location of MySQL data folder, after creating 32,000 database on that location, I want to change the data directory to ...

Calculating unique bids on an product

Products (productId INT PK, bidCount INT) Bids(bidID INT PK, productId INT, userId INT, isCounted BIT, created DATETIME) There is a 1:many relationship between a product and bids. Each biding cycle lasts for 1 day, so I need to track unique bids per day and update the bidCount column. I set isCounted = 1 for every row that I process d...

Adding some logic to SQL query

Hi, First of all I'm really not that great at sql, with that said, onwards to the question: Lets say I have a table called Abilities. In this example Abilities has a ID, PersonID, Text. Lets say I do a search where I specify that I want to distinct list every person that has the ability to 'Fly', 'Drive', 'Sing' but do NOT have the ab...