sql

How should I handle updating data in a one-to-many relationship database schema?

Lets say I have a database similar to the following: Table: People id | name | age ---+------+----- 1 | dave | 78 Table: Likes id | userid | like ---+--------+------- 1 | 1 | apples ---+--------+------- 2 | 1 | oranges ---+--------+------- 3 | 1 | women What would be the best way to handle updating daves data? Cu...

Get me the clear picture of outer joins in Oracle 9i

Outer joins seem to me a little bit confusing. Is there anyone can get me a clear picture of outer joins (right, left and full)? ...

Zend_Db: Prepared statement not processing parameters

I am using Zend_Db with the Pdo_Mysql driver. This query does not give any results: $s = $db->prepare('SELECT ET.id FROM elementTypes AS ET, language AS L1 WHERE L1.strId = ET.dispName AND L1.language = ?'); $s->execute(array(2)); pr($s->fetchAll()); If...

Receiving Error message when performing Update Statement

Receiving Error message when performing Update Statement, but database is being updated. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1 Issue with function update() function update($pUInput) { $sql = mysql_query("UPDATE tb...

SQL query search ampersand &

Need to write a SQL query to search special character in a column. Text needed to search is 'R&D' but issue is that SQL server 2005 is taking it as a logical operator. Any help? ...

SQL vs noSQL build examples

Could I have a list of type of applications I should build on a sql database and a list of applications i should build on a nosql database? ...

Finding Out If Datetime Is In a Specific Time Interval Using SQL

Hi everybody, How can I find out if a datetime column in my table is in a specific hour interval (e.g 13:07 - 15:15) and in a specific day (e.g Thursdays) in a SQL select statement? Thanks, ...

Query with three tables

select record1.fname, record2.fname, record3.fname from record1, record2, record3 where record1.country= record2.country or record1.country=record3.country What is the equivalent query of the above code if you will use inner join and left join? I not yet that familiar with join, but I know how to use join if there are only two table...

PDO cannot compare mysql ENUM using integers in prepared statements

I am using PDO and prepared statements, but i cannot seem to get any results when comparing an ENUM field with an integer. Example: $db = new PDO('mysql:host=localhost;dbname=****', '***', '***'); $s = $db->prepare('SELECT id FROM t2 WHERE lang = ?'); $s->execute(array('en')); // Works print_r($s->fetchAll()); $s->exec...

send notification message to client

Hello everybody, I have a table in server. I want to show a notification message in client when that table will update. How can i do that? excuse me because I'm beginner in SQL ...

How to hide column name in view. Using Visual Studio ASP.net and SQL.

Hello, how to hide the name of the requested column when i show the data in an ASP.Net web application. problem is: i request some data from a sql table and show it on an asp.net webpage. now it shows the data but adds the column name in front (both in Listview and DataList). Like this: Columname: Data. How do i avoid the columnname bee...

Should I use a database trigger for the following problem?

Hi, I've been given the following task: An external source will write a name, datetime and value to a database table (table A) at random intervals. I need to copy this data to another table (table B) and delete the row in table A. If the name doesn't exist in a lookup table then the row needs to remain in table A until it does and then...

Complex Cursors for returning multiple rows

Each row in a cursor should be joined with another table and the whole result should be returned a one cursor Say cursor1 return 5 rows. Each of these 5 rows should be joined with table1. and the final result for all the 5 rows should be returned a 1 row. Plz help ...

(My)SQL in Flex - any good libraries?

Hello! I need to develop a small Flex application that needs to access a MySQL database. Since I have little experience in server-side Java, PHP programming I would prefer to use a library/framework that allows me to write SQL queries in ActionScript/MXML. After a bit of research, I have come across two 3rd party libraries, AS3FlexDB(...

Dynamic Declare statements SQL Server

Hi, I'm using the varchar(MAX) value for text but as I'm building up the huge SQL it cuts the ending off. Is there any way I can create a Dynamic Declare statement that I can then join together with others when executing the sql? e.g. something like: DECLARE @sSQLLeft + Convertvarchar(4),@index) varchar(MAX) ...

Using 2 fields in ORDER BY clause

I have a page that show "special offers", and i need to order the results by discount value. Besides i want that products with quantity=0 are shown at the end of the list (regardless of the discount value). So, there is any way to do that using only SQL? I mean... if i set "ORDER BY discount, quantity DESC" the list show products ordere...

SQL query using UNIONS and GROUP BY

Hi Guys! The Query: SELECT max(image_url), Model_Name FROM ( SELECT max(image_url), Model_Name FROM dbo.proinfo_vodafone WHERE Brand_name='Nokia' UNION SELECT max(image_url), Model_Name FROM dbo.proinfo_3 WHERE Brand_name='Nokia' UNION SELECT max(image_url), Model_Name FROM dbo.proinfo_t WHERE Brand_nam...

full-text search sql server 2005

Hi, I have got hold of a sql server 2008 developer edition and this is my data: if exists (select * from dbo.sysobjects where id = object_id(N'test') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table test create table test ( Id INT IDENTITY NOT NULL primary key, data NVARCHAR(255) not null ) insert into t...

How to Display Records from a Database in a Browser?

I'm new to PHP and SQL, and I'm trying to display records from a database in a browser. I'm first trying to test out how to display records when a user selects 'SELECT' from a dropdown menu. created a function called selectById() // function selectById ------------------------------------------------------------------------------------...

Error converting data type nvarchar to datetime.

Using Vb.net/SQL Server 2000 updating a row via a gridview/sqldatasource Stored proc: @ISTag varchar(10), @PCISTag varchar(10), @User varchar(50), @Date_Start datetime, @Date_End datetime, @Status varchar(50), @Cost money, @Notes varchar(500), @CreatedBy varchar(50), @ModifiedBy varchar(50) AS BEGIN -- SET NOCOUNT ON added to preve...