sql

How can i add a condition string to an sql query in an var type

Im working on an source code with an sql query in a VAR type like var query = select ... from ... where ... ; is it possible to add an dynamic "where clause" like string condition = "where x.x > x.y"; e.g. var query = select ... from ... + condition; Iam sorry for my bad english ...

how to calc ranges in oracle

Hi mates, I have a table defining ranges, e.g.: START | END | MAP 1 | 10 | A 11 | 15 | B ... how do I query into that table so the result will be ID | MAP 1 | A 2 | A 3 | A 4 | A 5 | A 6 | A 7 | A 8 | A 9 | A 10 | A 11 | B 12 | B 13 | B 14 | B 15 | B ... I bet its a easy one... Thanks for the help f. ...

Storing & Querying Heirarchical Data with Multiple Parent Nodes

I've been doing quite a bit of searching, but haven't been able to find many resources on the topic. My goal is to store scheduling data like you would find in a Gantt chart. So one example of storing the data might be: Task Id | Name | Duration 1 Task A 1 2 Task B 3 3 Task C 2 Task Id | Predecessors...

How to SQL join two tables so that all entries of the left one are in the result even if there is no matching entry in the right one?

Hi everybody, I have spent several hours with this SQL problem, which I thought would be easy - I still think it should be, but obviously not easy enough for me (not an SQL expert). I would be glad if you could help me with this. I have stripped this down for this example. Imagine two tables: PRODUCT -ID -NAME REVIEW -ID -PRODUCT...

Things which can be done with MYSQL instead of involving PHP

What are the must-know MYSQL functions (like IF etc..,) which every web developer should know? ...

Delete entries from releted tables

I have got 2 tables: Contacts and Users. Contacts table contains user_id which are referring to id in Users table. Contacts also contain list_type column. Contacts: user_id, list_type Users: id, data How can I delete entries/rows from both tables (Contacts and Users) that are referring to given list_type? The trick is that i don't wa...

Best way to implement a Notes Table for many entities Tables in SQL

i have many tables : customers, prospects, friends.. They all have some Notes. Question 1: Should i have one Notes Table shared with all the parent Tables. OR Should i have a NotesCustomer, NotesProspects, NotesFriends Tables ? Question 2: If the best solution is the first one then this general Notes table should then have a FK to th...

Building a datasource object from SQL

Did a quick search on SO, couldn't find what I need: I am in process of trying out a new control suite (DevExpress ASP) and need to bind the TabStrip control to a datasource from SQL. The online documentation states that "any object that implements the IHierarchicalEnumerable or IHierarchicalDataSource interface (e.g. SiteMapDataSource,...

Return @@RowCount in LINQ to SQL INSERT

I am in the process of migrating some legacy code to LINQ to SQL and I am having some difficulty with the following Stored Procedure. BEGIN INSERT INTO tblCMOEncounterHeader ( submitter_organization_id, submission_date, begin_posting_date, end_posting_date, number_of_records_transmitted) ...

Correct this SQL Query: error "Microsoft Jet database engine cannot find the input table or query 'IF' "

Hi every one, i should say hi experts :D . Help me with this pretty code :) The database: "ID (Primary key)" | "Title" 0 | "title1" 1 | "title2" 2 | "title3" 3 | "title4" Sub AddRecord(ByVal Table As String, ByVal Columns As String, ByVal Record() As String) D...

SQL in clause with dummy rows

Hi, I'd really like know if it's possible to do a select statement, which returns exactly same records, that we put into in clause? Sample: select * from table where table_id in (1, 2, 3, 666); This table for an example has only id-s from 1 to 100, so this select will return only three rows. What I need to do, to get also one (proba...

Update same column in several sql tables using C#

Hi Guys! The Scenario: I have a mobile phone comparing asp.net website which displays deals of various networks. The data about the deals we receive from the networks is in an excel sheet. We import the data from the excel sheets to the tables of each network in our database. Now, the data that we receive is not consistent for every net...

Update multiple columns in multiple rows in one sql statement?

This pseduocode (inaccurate SQl) shows what I want to do. update tableA (colA, colB, colC, colD) select b.colA, b.colB, c.colC, c.colD from tableB b left outer join tableC c on b.id = c.id inner join tableA a on c.myNum = a.myNum inner join tableD on a.newId = f.newId where f.imported = 1 How can...

Create delimited string from a row in stored procedure with unknown number of elements

Using SQL Server 2000 and Microsoft SQL Server MS is there a way to create a delimited string based upon an unknown number of columns per row? I'm pulling one row at a time from different tables and am going to store them in a column in another table. ...

Calculations on Subquery in strong typed dataset

Hello, following background: i have a Table-valued Function that returns a Table that is a kind of filtered view(views can not be parameterised) on a large table. Now i need many row count values on different conditions. Is it possible to get all count values in one query without having to query this function for every condition? For th...

what is dynamic stored procedure ? what is their relation with dynamic functions and dynamic queries ?

how do we implement dynamic stored procedure and do they relate to dynamic functions and dynamic queries in sql server ? Kindly enlighten... ...

Syntax for ColdFusion Left() function

I have a SQL statement, in ColdFusion, and I want to limit the size of one field. Neither of the following appear to work (they don't give errors, they just don't limit the field). INSERT INTO ListItems VALUES ('#qGetListID.ID#', <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#listItems[i].itemID#" />, <cfqueryparam cfsqlt...

What is wrong with this format

SELECT .... GROUP BY c.city_id ORDER BY p.name desc UNION SELECT ... GROUP BY c.city_id, p ERROR 1221 (HY000): Incorrect usage of UNION and ORDER BY is there a way to have this format because i want the top query to have an orderby do i need to have the same orderby on the bottom query ...

Process optimization for large sets of data

I currently have a project where we are dealing with 30million+ keywords for PPC advertising. We maintain these lists in Oracle. There are times where we need to remove certain keywords from the list. The process includes various match-type policies to determine if the keywords should be removed: EXACT: WHERE keyword = '{term}' CONTAIN...

mysql rows to columns, text type

If i have a table of data like Option_id|Component_id|Option_parent|Option_name|Option_value 1 1 0 id 2 1 1 option1 Some value 3 1 1 option2 Other 4 1 0 id Value 5 1 4 ...