sql

Inner Join

$query4 = mysql_query("SELECT * FROM comments WHERE content_id = '$id' AND content = 'thread' INNER JOIN users ON comments.poster = users.id ORDER BY comments.date ASC"); while ($comment = mysql_fetch_array($query4)) { } all the tables and columns exist and i am connected to the database but it stil...

How to use one query for two tables representing a poll with question and multiple answers?

Hi, I have two tables poll and poll_answers, which represent a poll and the options to choose from to answer a question from the poll. EX: DO I suck at SQL? yes yes, you do change craft and the co-responding tables: poll pollID pollQuestion 1 | DO I suck at Sql? poll_answers pollAnswerID pollAnswerText pollID 1 | yes | 1 2 ...

Hidden features of SQL Server 2009 AF edition and mySQL9.1.4 - fuzzy logic

It was reveled today that the new standard of SQL will include specification of some new database operations that will allow using databases for Fuzzy Logic operations. This new functionality is said to be implemented in SQL Server 2009 AF Edition and mySQL9.1.4 There were 2 new keywords introduced The new keyword is called JOINT which...

SQL Loader : Load into 2 Tables from 1 controlfile and 1 CSV

Table T1 Structure:col1 number,col2 number Table T2 Structure: col1 number,col2 number,col3 number csv file: row1:1,2,3,4,5,6 row2:1,2,3,4,5,6 I want data in Table T1 as: col1 col2 ===== ==== 1 3 1 3 I want data in Table T2 as: col1 col2 col3 ===== ==== ==== 1 3 5 1 3 5 following ...

Spring Hibernate SQL Query

I have a VO class which has the getter and setter of another VO class too. For example: Class DocumentVO{ PrintJobVO job; PrintRunVO run; String id; getters and setters.. } Now I have a requirement to use the Native SQL Query using spring hibernate. When I want to map the ids I have a problem. My query is, select {r.*},{d...

FROM clause necessary in every SELECT statement

is the FROM clause necessary in every SELECT statement?Thanks.. ...

How to make a search engine for my apps

Duplicate of: What is a good search engine for embedding in a web site. I mainly build apps in asp.net using a ms sql backend. Does anyone have a dummy guide for making a good search engine? I've been told not to you like statements in my stored procedures. If I don't use like, how do I search for terms with in all my columns conta...

SQL Server physical data layout for tables without indexes

I'm curious to see if anyone knows how is the data physically arranged in tables that don't have an index (not even a PK). In this question the OP claims it is taking a long time to drop a clustered PK. I know that the clustered index is the data itself, but what would be the new data arrangement that explains the long processing time? ...

Changing the order of LINQ to SQL Inserts

I have two LINQ to SQL classes, CandyBar and DeliciousCandyBar that map to tables of the same name in SQL Server. There is a 0..1 relationship between CandyBar and DeliciousCandyBar. i.e, A CandyBar can have 0 or 1 DeliciousCandyBars. Conversely a DeliciousCandyBar has exactly one CandyBar. In LINQ to SQL class, they look (basically) l...

Count DIFFDATE Exceeding A Specified Value - Step 3

Along the same vein as the questions asked yesterday, I have another "count if" dilemma. Now I need to pull a count of the condition entries that meet the following parameters: ConditionLevelEntryID = 189 CheckoffDate is > 14 days from ConditionEntryDateTime CheckoffDate IS NULL and ConditionEntryDateTime is > 14 days old I have att...

Add property to LINQ that is combination of multiple tables?

I currently have 3 separate tables : Course, Category, and CourseCategory. CourseCategory is the connection only having the CourseID and CategoryId. I need a way in LINQ-to-SQL to add a Category property to Course objects that abstracts past the multiple tables. We need to change the application to only allow one category, but we don'...

Best way to change clustered index (PK) in SQL 2005

I have a table which has a clustered index on two columns - the primary key for the table. It is defined as follows: ALTER TABLE Table ADD CONSTRAINT [PK_Table] PRIMARY KEY CLUSTERED ( [ColA] ASC, [ColB] ASC )WITH (SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY] I want to remove this clustered index PK an...

How to write this SQL Statement

table1 has 3 columns: Id UserName SubmittedDate 1 Joe 1/1/2006 2 Joe 1/1/2007 3 Nat 1/1/2008 4 Pat 1/1/2009 I want to return this: Id UserName 2 Joe 3 Nat 4 Pat I just want just one record for Joe, the most recent one. How do I write this query? Thanks ...

I would like to extract the SQL queries from Crystal Report .rpt files, is there a way to do this?

I would like to extract the SQL queries from Crystal Report .rpt files, is there a way to do this? I don't have any of the Crystal Reports products, just the .rpt files. ...

How to get date part from datetime?

Duplicate: How to truncate a date in .net? I have datetime field containing '4/1/2009 8:00:00AM'. I want to get '4/1/2009' without the time. ...

SQL select value if no corresponding value exists in another table

I have a database which tries to acheive point-in-time information by having a master table and a history table which records when fields in the other table will/did change. e.g. Table: Employee Id | Name | Department ----------------------------- 0 | Alice | 1 1 | Bob | 1 Table: History ChangeDate | Field ...

Dynamic columns for Pivot

I have a table of equipment, a table of customers and a sparse table of equipment and customers. I want to produce a query that returns a 1 if the equipment/Customer table record exists and a 0 if it doesn't for each customer. There are only a small number of customers in this problem, so what I want back should look like this: Equipme...

Getting return value from stored procedure in C#

I have the following query: set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [dbo].[Validate] @a varchar(50), @b varchar(50) output AS SET @Password = (SELECT Password FROM dbo.tblUser WHERE Login = @a) RETURN @b GO This compiles perfectly fine. In C#, I want to execute this query and get the return value. My code ...

Why does Oracle think I'm missing a right parenthesis?

In Oracle 10i, I'm running the following command: ALTER TABLE jnrvwchnglst ADD ( jnrvwchnglst_userid NUMBER(10) NOT NULL DEFAULT 1 ) Yes jnrvwchnglst is an existing table and no jnrvwchnglst_userid is not an existing column. The Oracle error message is: ORA-00907: missing right parenthesis What's wrong with this query and why...

How do I (quickly) collate IDs from various tables?

I have three denormalized tables that I have to take at face value (data comes from some external resource). The three tables have different definitions, but they each describe the same object from different perspectives. object1 A B object2 A object3 B C object4 C The only commonality between these tables i...