sql

Handling multiple connection strings in ONE DataAccess Layer

I have an interesting dilemma. I currently have a DataAccess layer that has to work with multiple Domains and each one of those domains has multiple Database repositories depending on the stored procedure called. AS of right now I simply use a SWITCH statement to determine the Machine the application is running on and return the appropri...

mysql, use two select

hi, why i get error: Subquery returns more than 1 row SELECT name, cat_id, ( SELECT topic FROM category WHERE cat = u.cat_id ) AS topics FROM name u Thanks ...

SQL query in OO Base with where and if

Hello. I'm totally blank about sql, but im have to make sql query in OO Base. Query have to avoid compare, when cell in table is blank. I hope somebody will help me. SELECT "D"."Imię", "D"."Nazwisko", "D"."Data badania", "D"."Rodzaj auta", "D"."Obszar badany", "D"."Jednostka kierująca 1", "D"."Jednostka kierująca 2" FROM "Dane" AS "D",...

sql query validator

Hi, Is there any sql query validator in frontend side or in any language for validating the query syntax before executing in the database ?.In my current project i have to validate the the sql query in flex before it goes to back end ,coz it has to pass lot many layers before hitting database and the hitting the DB and coming back wit...

need updation for mysql query for choosing date range for reservation of a hotel room or any thing

Hi every one, i had a situation in my project that is as follows. while checking for the available rooms $sel_from_bookings="SELECT room_no FROM `booking` WHERE (('".$_POST['req_tdate']."' BETWEEN check_indate AND check_outdate) OR ('".$_POST['req_fdate']."' BETWEEN check_indate AND check_outdate)"; $sel_from_reserv="SELECT room_no ...

How do i create a Identity starting with a Letter first then numbers after?

I want to create data that contains info about my supplier making it auto generate his ID. for e.g: SupplierID i want it to appear as - SID001, SID002 all to auto genrate after each other. How do i do this with SQL? Please let me know thanks! ...

SQL Efficiency - Which is quicker?

Hi I'm doing a bulk insert but before inserting into the actual table I need to do some checks. So currently I'm inserting into a temp table but I've just seen that it's possible to declare tables. So my question is - Which is quicker? To CREATE or DECLARE. The table will have multiple SELECTS done on it and will contains around 200,000...

How to convert second into datetime's 108 format hh:mm:ss in sql server without writing function

select v1.*, datediff(ss,v1.dateofchange,v2.dateofchange) as acutaltime from vActualTime v1 left join vActualTime v2 on v1.rowno=v2.rowno-1 FK_PatientId FK_Status_PatientId DateofChange rowno acutaltime ------------ ------------------- ----------------------- -------------------- ----------- 3 ...

How to merge 2 rows in mysql

T1 F1 F2 F3 F4 a 2 2 NULL a 2 3 UK But i want only the result is a 2 2,3 UK if i do select How to achieve this ? i am looking out the result :a 2 2,3 UK and 2,3 is F3 field ...

How to get timestamp as timestamp from postgres?

Hi, I want to get data from potgree SQL. There is a column in type timestamp without timezone. Simple SELECT returns me formated date but I want timestamp in miliseconds simply. How I can do it in SQL? Thx for answers. Kamilos ...

Aggregating save()s in Django?

I'm using Django with an sqlite backend, and write performance is a problem. I may graduate to a "proper" db at some stage, but for the moment I'm stuck with sqlite. I think that my write performance problems are probably related to the fact that I'm creating a large number of rows, and presumably each time I save() one it's locking, u...

MySQL request WHERE ... IN ...

Hi, in a table "partners", i've a field "sites" which can contain values like 1,27,38,12 then, in a website which has ID n°27, i would like to get partners associated to this website. I tried this : SELECT * FROM partners WHERE 27 IN (partners.sites) It works if 27 is at the beginning of the string (eg: 27,1,128) but it doesn't wor...

Is it possible to write custom SQL in OrmLite?

Hello. I have a class which I want to persist with OrmLite and it stores most of its data in a HashMap. I want to map these fields to the table in Sqlite, leaving the ones absent in the map as null. Is it possible to override methods to save some record to the database with custom implementations using OrmLite? ...

Doctrine - how to get the SQL INSERT query, in the postSave() event?

I would like to get the exact SQL INSERT query that Doctrine generates when an object's save() method is called. Preferably, I would like to get it in the postSave() event of the model and log it in a txt file. For instance: <?php $user = new User(); // A Doctrine Model with timestampable behavior enabled $user->first_name = 'Manny';...

SQL and PHP - Submit form with an ID in URL (in wordpress)

I've been trying to find the best way to do this for a while now but cannot figure it out. I have a simple dropdown which auto populates based on an SQL query. When you press "search" I need it to go to a page with the url extension ?id=x where x is the id of the option they selected. $locations = $wpdb->get_results( $wpdb->prepare( ...

If I restore a database and overwrite the original is there any way to go back? SQL Management Studio

I do not have a backup available but I wrote over an existing database with a backup file. The problem is the one I wrote OVER had a Stored Proc that I need to get back. Any way to do this without a backup file of the database with the Stored Proc in it? ...

FIND_IN_SET question or..

Hello. Anyone could help me with a mysql Question? I have a row with a list of items, eg: '1','2','3','4','5','6','7','8','9' .. sets of 3 elements.. from 3 to 3.. Now how could i search into this with FIND_IN_SET above '4' and return from what sets it is. In that case, to tell me that is from set 2 SELECT FIND_IN_SET('''4''', REPLACE(`...

Complex rails find ordering

Hi, I am trying to do a find which orders results by their house name and then by the customer's last name. Customer.find(:all, :conditions =>['customers.id IN (?)', intersection], :joins => 'JOIN histories ON histories.customer_id = customers.id JOIN houses ON histories.house_id = houses.id', :order => "houses.name ...

Sql Parser in C# for syntax check Oracle statements

I want to parse the SQL code of a file .sql using C#. I want determinate Syntax Check of a file sql, specifically Insert, Update and Delete statements. Specifically is there any parser freely available which can parse the SQL code in C# .NET ? better is freeware, source code included, and easy use. I use Oracle ...

SQL Constraint IGNORE_DUP_KEY on Update

I have a Constraint on a table with IGNORE_DUP_KEY. This allows bulk inserts to partially work where some records are dupes and some are not (only inserting the non-dupes). However, it does not allow updates to partially work, where I only want those records updated where dupes will not be created. Does anyone know how I can support I...