sql

Excel/VBA: How to paste SQL query with proper string formatting

Hi folks, I've been writing some pretty long SQL queries in notepad and then pasting them into my VBA code as-is and then formatting the multi-line string correctly each line at a time. For example... In my text editor, the query looks like this. SELECT a, b, c, ..., n FROM table1, table2, ...

MySQL fetch a field where the field exists > x times in table

I'm trying to do the following in MySQL: SELECT DISTINCT field FROM table WHERE COUNT(field) > 10 Which fails with: 1111 - Invalid use of group function (from what I understand, you can't use group functions such as COUNT in the where clause?) What is the proper way of selecting (distinct) all fields which are present in at least N r...

Using nhibernate to filter by the value of an object in a child collection.

Here's the setup. NHibernate, Fluent NHibenrate and Nhibernate Linq The entities invoved are Fault - a record of a fault occuring Alarm - information about the fault, think of it as a fault type ( a list of all possible faults that can occur ) AlarmDescription - human readable description, one for each language A fault has an alar...

Converting timestamp to datetime in MYSQL

Do you lose any data when converting a timestamp to datetime in mysql? Also what are the major differences between the two? ...

Merge of two strings in Oracle SQL

Is there any way to merge two strings returned in a query like this: I have one string '<6 spaces>XYZ' and other string '<3 spaces>ABC<3 spaces>'. Basically each string is divided in 3 parts and two of any parts will be blank. I want to merge these two strings to produce the output: '<3 spaces> ABCXYZ'. Another example can be 'ABC<6 sp...

SQL Server full-text search

I want to use the full-text index to search word: How can I use 'contain' or 'freetext' to get the same result as "like '%dd%' "? If I use contain(table,'data'), it only finds "....the data is ...." How can I use contain search 'dat' to find data? ...

Updating table with new objects without mass delete through LINQ to SQL in C#

I am new to database programming and want some tips on performance / best practices. I am parsing some websites to scrap television episode infos and placing them into an MS SQL 2008 R2 relational database. Lets say i have a table filled with type Episode. When i start a new parsing, i generate a new list of Episodes. The thing is, ...

MongoDB or CouchDB or something else?

I know this is another question on this topic but I am a complete beginner in the NoSQL world so I would love some advice. People at SO told me MySQL might be a bad idea for this dataset so I'm asking this. I have lots of data in the following format: TYPE 1 ID1: String String String ... ID2: String String String ... ID3: String String...

Django Group By

Hello. I'm writing a simple private messenger using Django and am implementing message threading. Each series of messages and replies will have a unique thread_id that will allow me to string sets of messages together. However, in the inbox view ALL of the messages are showing up, I'd just like to group by the thread_id so that althoug...

inner join mysql tables

Ok here it is. i have two tables: products and product_sizes so basically my product table has id(primary key),name(product name)and size_id(foreign key from product_sizes) my product_sizes table has predetermined values: size_id name ------------------ 1 1x1 2 2x2 3 3x3 and here i have a workin...

sql: how to copy from one table into another table

table A's structure is a subset of table B, that means the table A's all the columns are the first columns of table B, but table B has more columns than table A. My question, what's the SQL statment to copy all the rows from table A to table B(the missing columns in table B will be kept empty). ...

MySQL, need some performance suggestions on my match query

I need some performance improvement guidance, my query takes several seconds to run and this is causing problems on the server. This query runs on the most common page on my site. I think a radical rethink may be required. ~ EDIT ~ This query produces a list of records whose keywords match those of the program (record) being queried. My...

Text Format in Excel using VBA

Hi, When I use WinSQL to run a SQL statement, the result is 20100803000001812. However, when I incorporate the SQL as a macro, the result is 2.01008E+16. What should I do in the macro in order to maintain the result as 20100803000001812 ? Thanks, Bob ...

multiple conditions in where clause

i am using mysql. this query is working fine: SELECT * FROM tablename where Date >'20091109' and id='11'; but below this query does not return any thing. SELECT * FROM tablename where Date between ('20091109' and '20081010') and id='11'; ...

SQL Server: Do I need to use GO statements between batches?

I have seen people use GO statement between batches of SQL code, but AFAICS it is not mandatory (SQL Server 2008). What are the benefits using GO statements between batches/sets of SQL statements? ...

Substring in sql...

I have a column in SQL table which would have data like this: "College: Queenstown College" or "University: University of Queensland" Text before the ":" could be different. So, how can i select only the text before the ":" from the column and text after the ":(space)"? ...

Does MySQL use existing indexes on creating new indexes?

I have a large table with millions of records. Table `price` ------------ id product site value The table is brand new, and there are no indexes created. I then issued a request for new index creation with the following query: CREATE INDEX ix_price_site_product_value_id ON price (site, product, value, id); This took long long t...

Resource for SQL

Hi All, I know this question might have asked severla times and i am asking it again.I am a java developers and when it comes to SQL i always make me nervous i do have idea about some basic SQL queries but above that i am mindless.. Can any one suggest me a good book or refrence material whcih can atleast give me a good solid foundation...

(.Net + SQL Server +Azure ) vs (Java + Oracle +Google App Engine) which is better for this project specifically? (Plz answer/Vote)

Hello Guys, I have to develop a ERP System for a 2,000+ end users Organisation. Could You please suggest me with comparable points that among (Java or .Net) in which technology I should invest money and time? Although I have done some average projects in both , but this project is going to be very big in near future in terms...

Another substring question in sql server

Below are the data in a column of my database: "ABC;123; TGH" "DEF;123456; TFG" How can i get the text "123" and "1234546" from both the data above? ...