sql

how do i display all the tags related to all the feedbacks in one query

Hi, I am trying to write a sql query which fetches all the tags related to every topic being displayed on the page. like this TITLE: feedback1 POSTED BY: User1 CATEGORY: category1 TAGS: tag1, tag2, tag3 TITLE: feedback2 POSTED BY: User2 CATEGORY: category2 TAGS: tag2, tag5, tag7,tag8 TITLE: feedback3 POSTED BY: User3 CATEGORY: cate...

update statement in sql server 2005

Consider the following Dig, Assume that all the three tables have a column Is_Deleted by default it is set to 0... I want to update Is_Deleted=1 field of Customers table where CustId=2 only when the rows containing CustId=2 and Is_Deleted=1 in Orders and OrderItems Tables... I dont want to use Cascade option.. Any suggestion ...

Group by and non distinct columns and data normalization

Hello Everybody!! I have a large table(60 columns, 1.5 million records) of denormalized data in MS SQL 2005 that was imported from an Access database. I've been tasked with normalizing and inserting this data into our data model. I would like to create a query that used a grouping of, for example "customer_number", and returned a re...

Table row referencing one table or another

I've got one table containing some sort of items, and two tables (a and b) to which these items belong to. One item refers to either one row in a or one row in b. One a or b can have multiple items. Is there a better design than the following (using Oracle 10)? Any pitfalls to watch out for? id a_id(fk) b_id(fk) 1 1 ...

Should I store my Enums at database level or in the application logic (.NET)?

Hi, I have a table, lets call it Objects. It has a predefined set of records looking like this: ObjectId ObjectName 1 Salmon 2 Trout 3 Seabass 4 Shark Etc.. So, this I would like to implement somehow as an enum. But what's the best way, implement it in the database creating tables for it or in the app...

inserting if in a select query

How can i do something like this ? SELECT (IF(SUM(Costo) > 0) SUM(Costo) ELSE 0) AS Expr1 FROM TDP_NotaSpeseSezB ...

How can remove lock from table in SQL Server 2005?

I am using the Function in stored procedure , procedure contain transaction and update the table and insert values in the same table , while the function is call in procedure is also fetch data from same table. i get the procedure is hang with function. Can have any solution for the same? ...

Mysql subquery : Trying to get the last order from a customer

Sorry , maybe it's trivial but I can't find a way to do this : table customers customer_id customer_email customer_newsletter (1=yes/0=no) table orders order_id customer_id order_status (1=ok/0=no_ok) Each customer can have zero, one or many orders. I'm trying to make a query to get all the emails of the persons who are : ...

user activity database structure

Hello. I am working on a community website. I want to show the user's activity in 2 places in the website. The User "A" Profile. The Friends page of the user "A" friends. "What are your friends doing?" The tables for instance are: members members_gallery members_videos members_friends my problem is in the Sql structure. I've ...

Moving a Point along a Path in SQL Server 2008

I have a geography field stored in my database, holding a linestring path. I want to move a point n meters along this linestring, and return the destination. For example, I want the destination point 500 meters along the linestring starting from its beginning. Here's an example -- what is the YourFunctionHere? Or, is there another w...

Sql value which isn't for the needed date but first available

I've got this SQL QUERY in MS SQL 2005/2008 database which gets me Money Amount, Money Currency, Money Time and Currency Converter. I left join it with Table that has gathered information from polish national bank about currency converter per each day. Here's the query: SELECT t1.[TransakcjeGotowkoweKwota], t1.TypyWaluty, ...

Close SQL connection Java Webservice

Hello, I am programming a WebService in Java that create and call this class : public class Manager{ private Connection aConnection; public CacheManager(){ //We get a connection aConnection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/mydb?user=root&password="; ...

Converting Data in SSIS

This is probably an easy task in SSIS but having little experience with the tool and having failed to find the answer in the documentation, I turn to the experts here. I appreciate any and all help I might get. I've got an SSIS package that reads the contents of an Excel spreadsheet and dumps the information into a database table. Tha...

Reports against a single SQL Table

I'm looking for a freeware program that is pretty much BusinessObjects. We have 1 SQL table which has loads of data in it that users constantly want reports from. Everytime they ask it's an ad hoc query written just for the moment. It would be much nicer to be able to give users a solution to create there own reports. Kind of like Bu...

When is a good situation to use a full outer join?

I'm always discouraged from using one, but is there a circumstance when it's the best approach? ...

SQL error in php

Hey, I wrote some code for extracting some information out of the database and checking to see if it met the $_COOKIE data. But I am getting the error message: 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 ')' at line 1 My code so far is: $...

Do I need to normalize this MySQL db?

I have a classifieds website which uses SOLR to search for whatever ads the user wants to search for... SOLR then returns the ID:s of all the matches found. I then use the ID:s to fetch and display the ads from a MySQL table. currently I have one huge table containing everything in MySQL. Sometimes some of the fields are empty because f...

Foreign key reference to table in another schema

I tried to create a foreign key on one of my tables, referencing a column of a table in a different schema. Something like that: ALTER TABLE my_schema.my_table ADD ( CONSTRAINT my_fk FOREIGN KEY (my_id) REFERENCES other_schema.other_table(other_id) ) Since I had the necessary grants, this worked fine. Now I wonder if there...

Oracle find a constraint

I have a constraint called users.SYS_C00381400. How do I find what that constraint is? Is there a way to query all constraints? ...

SQL:UpdateText function :How to use ?

can anyone show me an example of using SQL server UPDATETEXT funciton.I want to apply some text replacement from one column(which is of type text) from one of my table ...