sql

SQL Select queries

Which is better and what is the difference? SELECT * FROM TABLE_A A WHERE A.ID IN (SELECT B.ID FROM TABLE_B B) or SELECT * FROM TABLE_A A, TABLE_B B WHERE A.ID = B.ID ...

SQLAlchemy custom sorting algorithms when using SQL indexes

Is it possible to write custom collation functions with indexes in SQLAlchemy? SQLite for example allows specifying the sorting function at a C level as sqlite3_create_collation(). An implementation of some of the Unicode collation algorithm has been provided by James Tauber here, which for example sorts all the "a"'s close together wh...

how to 'scale' these three tables?

I have the following Tables: Players id playerName Weapons id type otherData Weapons2Player id playersID_reference weaponsID_reference That was nice and simple. Now I need to SELECT items from the Weapons table, according to some of their characteristics that i previously just p...

Mysql storing quotes as '

I have some PHP code which stores whatever is typed in a textbox in the databse. If I type in bob's apples, it gets stored in the database as bob's apples. What can be the problem? The table storing this has the collation of latin1_swedish_ci. ...

How do I pass parameter as Date in vb.net web ?

I have a mail webform where I have to show the user only (-1) one day behind messages, so how do pass (yesterday)date as parameter and retrieve the only records of one day back ? This query is for 'ALL' messages, but I need to filter (yesterday) one day back messages and add a hyperlink or add in a dropdown ? select MSG_SRNO,MSG_SUBJECT...

No_data_found exception is propagating to outer block also?

In my code i am entering the salary which is not available in employees table and then again inserting duplicate employee_id in primary key column of employee table in exception block where i am handling no data found exception but i do not why No data found exception in the end also? OUTPUT coming: Enter some other sal ORA-01400: can...

How to increase my Web Application's Performance??

I have a ASP.NET web application (.NET 2008) using MS SQL server 2005, I want to increase the performance of the web site, If anyone have an article contains steps to do that, step by step , In SQL(Indexes, ..... etc.) and in the code. Thanks in advance Best Regards ...

[Flex 4 and .Net] Retrieving tables from SQL database

Hi everyone, As the title says, I want to retrieve tables of data from a SQL database, using Flex 4 and .Net WebService. I'm new to both Flex and DotNet. Please tell me a proper way to do it. This is what I've done so far: Retrieving an array of string: (this works) .Net: [WebMethod] public String[] getTestArray() { String[] ...

How to select rows which start with digit in PostgreSQL?

Need to get rows starting with digit e.g. '1test', '32 test'. I tried SELECT * FROM table WHERE name LIKE '[0-9]%' as I used to do in MSSQL but it wasn't successful. ...

SQL query to show what has been paid each month

I'm looking for help to create a query, to solve the following problem: Let's imagine the row: Name StartDate EndDate Paid James 10-10-2010 17-02-2011 860 And heres the schema for the table as requested: payment_details (name VARCHAR(50) NOT NULL, start_date DATETIME NOT NULL, end_d...

ANSI SQL question - how to insert or update a record if it already exists?

Although I am using mySQL (for now), I dont want any DB specific SQL. I am trying to insert a record if it doesn't exist, and update a field if it does exist. I want to use ANSI SQL. The table looks something like this: create table test_table (id int, name varchar(16), weight double) ; //test data insert into test_table (id, name...

What can cause legit MySql INSERT INTO command to fail?

I can't figure out what's causing my INSERT INTO's to fail to certain table in MySql. I can manage them to other tables. The table looks like: CREATE TABLE IF NOT EXISTS `Match` ( `id` int(11) NOT NULL AUTO_INCREMENT, `match_no` int(11) NOT NULL, `season` int(11) NOT NULL, `hometeam` int(11) NOT NULL, `awayteam` int(11) NOT N...

Help with this query in Access

ID- DATE- NAME 10100- 2010/04/17- Name1 10100- 2010/04/14- Name2 10200- 2010/04/17- Name3 10200- 2010/04/16- Name4 10200- 2010/04/15- Name5 10400- 2010/04/01- Name6 I have this fields(and others too) in one table. I need to do a query which return the ID with your respective name where more recently date for example th...

How does one concatenate database values into a string?

I would like to string together database values into a string. Something like $a "text" $b. And then use the entire string as a variable, let's say $c. Is it better to do this at the database level? Will php use lots of resources to do this? ...

Creating Composite primary keys in a many-to-many relationship in Entity Framework

Hello, I have two tables that are connected via a join table in a many-to-many relationship in the Entity Framework. I need to add a composite primary key in the join table for the two columns that are related to the joined tables via standard foreign keys but I'm sure how to do that. ...

How to add an additional column in a table by comparing the values in a different column

I have a table with the following records id name city 1 aaa NY 2 bbb NY 3 ccc LA 4 ddd LA 5 eee NY I want the table with an additional column by comparing the 'city' column. The values in the col4 should have '1' for every unique value in 'city' column and '0' for the repeating values in 'city' column. id ...

How to get max row from table

HI I have the following code and a massive problem: WITH CALC1 AS ( SELECT OTQUOT, OTIT01 AS ITEMS, ROUND(OQCQ01 * OVRC01,2) AS COST FROM @[email protected] WHERE OTIT01 <> '' UNION ALL SELECT OTQUOT, OTIT02 AS ITEMS, ROUND(OQCQ02 * OVRC02,2) AS COST FROM @[email protected] WHERE OTIT02 <> '' UNION ALL SELECT OTQUOT, OTIT03 AS ITEMS, ROUND(OQC...

Recommended SQL Practice and Books

Hi, Please recommend me some books and practices for me. I am quite weak in SQL though not that bad in C# and VB.NET. Thanks. ...

SQL Server Error 26 (Error Locating Server/Instance Specified) Only When Debugging

I have a simple asp .net web project I'm working on, and while normally everything is going fine, if I try to debug the site, I get "SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified". I'm not sure if its a weird code issue or a weird SQL Server Issue, but here are the system specs anyway. My dev machine is W...

How to add SQLite (SQLite.NET) to my C# project

I followed the instructions in the documentation: Scenario 1: Version Independent (does not use the Global Assembly Cache) This method allows you to drop any new version of the System.Data.SQLite.DLL into your application's folder and use it without any code modifications or recompiling. Add the following code to yo...