sql

MySQL: Fuzzy text search vs joins...

I've been assigned to build a questions & answers widget for my company. Many different departments in the company will want to use this widget on various websites and they will want to filter questions based on specific and unique criteria. The battle here is scalability vs efficiency. Should I: A) Make unique mapping tables in the ...

How to convert products to product-with-pack-sizes using the largest pack size

For a food online-ordering application, I have worked out how many ingridients we need (which we call StockItems), but need help converting that to what we should order based on what sizes they come in (which we call SupplierItems -- i.e. StockItems + PackSizes). If we take apples as an example, we need to order 46 (that bit has already...

How to break queries using regex in php

Suppose I have the following string: insert into table values ('text1;'); insert into table values ('text2') How do I break those queries (get each individual query) using regular expressions? I've found a very similar problem: http://stackoverflow.com/questions/958095/useregex-to-find-specific-string-not-in-html-tag ...but it uses...

Group SQL results by week and specify "week-ending" day

I'm trying to select data grouped by week, which I have working, but I need to be able to specify a different day as the last day of the week. I think something needs to go near INTERVAL (6-weekday('datetime')) but not sure. This kind of SQL is above my pay-grade ($0) :P SELECT sum(`value`) AS `sum`, DATE(adddate(`datetime`, I...

Question about Java programming using Derby database

Hey, everyone! I'm havin an error while trying to execute this piece of sql code... The error I'm getting is: Encountered "(" at line 1, column 45 The piece of code is: ALTER TABLE APP.RESPOSTAS ADD coluna" + (numColumns + 1) + " INTEGER(1) AFTER coluna" + numColumns; Can anyone help me? Thank you all! ...

database: summarizing data which expires

I'm struggling to find an efficient and flexible representation for my data. We have a many-to-many relationship between two entities which have arbitrary lifetimes. Let's call these Voter and Candidate. Each relationship has a measurement which we'd like to summarize in various ways. These are timestamped and are guaranteed to be within...

How to generate a virtual table to generate a sequence of dates in PostgreSQL?

I'd like to generate a list of dates with the hopes of joining with another table, but I don't know what syntax to use, something similar to this: SELECT dates.date, transactions.account_id, transactions.amount FROM (...) as dates LEFT JOIN transactions ON transactions.date = dates.date WHERE dates.date >= '2010-01-01' AND dat...

Loop through each record from a table and a calculated record into other table in Oracle

I am new to Oracle 10g. I have couple of tables as shown below: INCOME_MASTER INCOME_ID NUMBER(10) sEQ NUMBER, INCOME_TYPE VARCHAR2(10), INCOME_DATE DATE INCOME_DETAILS INCOME_DETAILS_SEQ_NO NUMBER(10) SEQUENCE, INCOME_ID NUMBER(10), ITEM_ID NUMBER(10), ITEM_VALUE NUMBER (10,...

mysql rename table column name

How to rename the table field in table xyz, Fields are manufacurerid,name,status AI,PK,int Want to rename to manufacturerid , I tried using phpmyadmin panel , its not working, show error, MySQL said: Documentation #1025 - Error on rename of '.\shopping\#sql-c98_26' to '.\shopping\tblmanufacturer' (errno: 150) ...

How to call C# function in stored procedure

SQL Server 2005 supports CLR so it means we can use CLR in backend so how to do that, I have some function in c# which do some complex manipulation with date-time variable now I want to use those functions in SP. First of all IS IT POSSIBLE TO DO THIS. ...

left join with condition for right table in mysql

Hi, I have been trying to wrap my head around this issue but I am not making much progress. My goal is to do a left join between two tables with criteria for the right table. I would like to see the list of all products and prices for the current day even though there is no pricing row for the current day. Here is an example of the c...

How to remove duplicate values inserted into an identity column in a table?

By some setting as using IDENTITY_INSERT we have duplicate entry in identity column, What is the best method of removing duplicate entry. I have a table Details With column DetailID | FKey | Col1 | Col2 | Col3 | Col4 DetailID is "Identity" and FKey is foreign key with another table. Now we have already 240000 record. Some one used "I...

how to store "thai" language data in my SQL database

plz help me friends ...

How does MySQL evaluate Text and VarChar fields when compared to booleans?

Like select * from table where text_field; What would get pulled? ...

Creating a multi-table SQL database in android

I'm trying to create a multi-table database for my android application. I'm following the suggestion given on this site http://androidforbeginners.blogspot.com/2010/01/creating-multiple-sqlite-database.html for doing it. I keep on getting the error below. The error seems to be cause by the onCreate of the databaes tables. If you look at...

Trigger on Select

I want to return different results to user when using Select because it returns wrong value and i cant use view or something else because its third party appliction. I want to make instead of his select perform another select trigger or any thing else. ...

Getting total number of rows using SQL_CALC_FOUND_ROWS in Zend DB Table Select

Is there a way to get the total number of rows in Zend db select like with using SQL_CALC_FOUND_ROWS in a regular mysql query. I haven't been able to find a similar functionality for this apart from running the same query without the limit clause. ...

Comparing Time in SQL Server 2008

Here is my table. I need a query which returns the shift id for a specified time How can I get the value? shift_ID shift_From shift_To 1 2010-09-21 10:00:00.000 2010-09-21 18:10:00.000 2 2010-09-21 20:00:00.000 2010-09-21 05:00:00.000 Suppose I am giving 02:00:00 as input I need to get the shift ...

How to get the products that all Warehouse exist?

I have a question as the title,I wanna get the products which appeared in every Warehouse, I have no idea when i thought long time,i found i am so beetleheaded, Thare are three tables in my sql server database: Product ( productID, name,model, size, color ) Warehouse ( warehouseID, name, address ) Inventory ( warehous...

Create computed column with string in formula

I want to create a computed column in SQL SERVER and set the formula to this ([Category] + '.aspx?ID=' + [Post_ID]) Not working though......what am i missing? Category and Post_ID are current columns in the table ...