sql

SQL Error: "There is already an object named XXXX in the database"

Hi Guys, Here's my query. What I want to do is run this query every week so table PlanFinder.InvalidAwps will have new records. But when I run the query it gives me this error : There is already an object named 'InvalidAwps' in the database. I can't change the table name. It has to remain the same. So how can I run this query every...

Dataset column always returns -1

I have a SQL stored proc that returns a dataset to ASP.NET v3.5 dataset. One of the columns in the dataset is called Attend and is a nullable bit column in the SQL table. The SELECT for that column is this: CASE WHEN Attend IS NULL THEN -1 ELSE Attend END AS Attend When I execute the SP in Query Analyzer the row values are returned a...

Is the join query correct?

I have multiple tables that I want to join to get a specific result. Tables are: ad_categories, ad_image, ad_data, ad_location I need a row output for every one of the following rows in the ad_categories table, regardless if there exists data for any of these categories for a specific location when using the WHERE conditional. mysq...

Query returns "No data found" JSP/Oracle

I've been looking this over for a while now and can't seem to pinpoint the problem. Does anything stand out that would cause a java.sql.SQLException: No data found ResultSet rs = null; rs = s.executeQuery("SELECT * FROM customer"); out.println("<tr><th>Customer ID</th><th>First Name</th>&nbsp;</th></tr>"); while(rs.next()) { ou...

Python doesn't save data to sqlite db.

This is my code: conn = sqlite3.connect(nnpcconfig.commondb) cur = conn.cursor() query = ['2124124', 'test2', 'test3', 'test4', 'test5'] cur.execute("insert into users(id, encpass, sname, name, fname) values (?, ?, ?, ?, ?)", query) conn.commit cur.execute("select * from users") for row in cur: print row This code works, returning...

Linked server and temp table issue

I had our vendor create a linked server (SQL Server 2008) to our Server (SQL Server 2000). This was in response to an issue I had with the vendor changing a data type to varchar(max). I was informed that I should create a link from 2008 to 2000 to resolve the issue. Now that I have accomplished this task, when I run my query that links...

How to move records from one table to another in linq

I have a ProductLevel table in an SQL database. It contains the products for a store. I want to copy these records into a ProductLevelDaily table at the time the user logs onto the hand held device in the morning. As they scan items the bool goes from false to true so at anytime they can see what items are left to scan/check. From the ...

Automatically generate SQL INSERT statements with data that respect database constraints

Here is a simple situation. (My apologies my SQL is quite rusty.) (I am using MySQL and Java but it should not matter too much.) Let's say I have two tables. Here is a simple SQL statement: A: insert into patient (patient_id) values (16) Now there is another table person, which has a person_id and that has to be constrained to ma...

How do I query the records using Miva

so i have a product in a system called miva I can get to this product just fine but i have another page that describes many products on one page and i need to either query the database for their information or somehow get all the information needed. I have no idea how do you that with this Miva site and where it even stores all these pr...

UNION syntax in Cakephp

Anyone knows a good way to make UNION query in CakePHP? I would like to avoid using $this->query();. With two tables t1, t2: SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id UNION SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id With three tables t1, t2, t3: SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id LEFT JOIN t3 ON t2.id = t3.id U...

How to join two tables mysql?

Hello friends, I have two tables: services id client service and clients id name email How to list table service and bring together the customer name that the customers table? field customer services in the table has the id of the customer at the customer table, I appreciate the help from you now ...

Capturing object dependencies at execution time in SQL Server

Is there any sane way to capture execution-time object dependencies in SQL Server? For instance, take this dynamic SQL scenario: DECLARE @table SYSNAME = 'SomeTable' DECLARE @column SYSNAME = 'SomeColumn' DECLARE @proc SYSNAME DECLARE @command NVARCHAR(MAX) = 'SELECT TOP 1 @proc = '+@column+' FROM '+@table EXEC sp_executesql @command, ...

Choosing tables for one-to-many relationships in MySQL

I was wondering if I allowed my users to pick which categories their post will be displayed in and they can pick multiple categories from one to many should my MySQL tables look something like the tables below? If not what should I add or delete? Here is my MySQL tables. CREATE TABLE users_categories ( id INT UNSIGNED NOT NULL AUTO_...

Subsonic.DataService Missing in Subsonic 3.0.0.4?

How do I execute QueryCommand Object in SubSonic 3.0.0.4 without DataService? ...

Is precalculation denormalization? If not, what is (in simple terms)?

I'm attempting to understand denormalization in databases, but almost all the articles google has spat out are aimed at advanced DB administrators. I fair amount of knowledge about MySQL and MSSQL, but I can't really grasp this. The only example I can think of when speed was an issue was when doing calculations on about 2,500,000 rows i...

sql query and asp.net

hello friends following is my query where displaylist is object if stringBuilder which have zero length sometimes but in that case it gives error incorrect syntax near FROM so how can i avoid this problem do i need to write a different query in if else form to avoid this or please suggest me a best solution to make and also from efficie...

Mysql access main table inside right joined subquery

SELECT id,region FROM ads RIGHT JOIN (SELECT * FROM ads a2 WHERE a2.region=ads.region LIMIT 4) AS regions ON regions.id=ads.id Says "unknown column ads.region". How to access main table column region? I need to fetch 4 rows for each region ...

What is wrong with my sql query of odata?

I am trying to get the number of users for each age. What is wrong with this sql query for odata.stackoverflow.com? select age, count(*) from users order by age group by age ...

How does SELECT from two tables separated by a comma work? (SELECT * FROM T1, T2)

Given 2 tables T1 and T2. T1 T2 --------- A 1 B 2 C 3 You make a query: SELECT * FROM T1, T2 What is the no: of rows that are fetched from this query? (a) 4 (b) 5 (c) 6 (d) 9 Answer is : 9 Question: Why is the answer "9"? ...

PHP secure user variable

On my website I have a variable called $user_data that contains input from a form. I then show this variable on the user page (via echo). What is the best method to avoid any security risks with this variable? I use strip_tags(), but it is not enough. This variable also gets saved to a MySQL database. ...