sql

Molap and Rolap

What is Molap and Rolap and whats the difference between these two ? ...

sqlite select with condition on date

I have an sqlite table with Date of Birth.I would like to write a query to select those records where the age is more then 30 . I have tried following but it doesnot work. select * from mytable where dob > '1/Jan/1980' select * from mytable where dob > '1980-01-01' ...

Firebird group by retrieve extra data

I have a table with 6 columns: id, a, b, c, d, e. id is primary key. I am trying to retrieve distinct a, b, c, max(d) for that group, and e that is present in the same row as max(d) is (column "id" is not relevant for my query). I tried this query: SELECT a, b, c, MAX(d), e FROM tablename GROUP BY a, b, c; but it gives me "Invalid e...

Use A Union Or A Join - What Is Faster

I just wonder if you had a table and you unioned it would it be more efficent then using a join?? I do know that the join creates more columns but this is more theoretical - Will the union need to do a nested loop scan of the other table like a join would have to? ...

Unioning Two Tables With Different Number Of Columns

I am stuck - I have two tables (Table A and Table B). These have different number of columns - Say Table A has more columns. How can I union these two table and get null for the columns that Table B does not have? ...

Return an array from mysqli stmt query

Hi there i'm trying to convert a site to use prepared mysql statements, however i'm having some trouble replacing my use of fetch_array(). The comments on php.net offer a solution which I would have thought should work but for some reason i'm getting strange undefined constant errors when calling a function via call_user_func_array() ca...

MySQL, put first letter of title field into another field?

Hello, I would like to select some data and put first letter of title field into another field. Is it possible? auto business Sports 1st offer I want to get something like that a|auto b|business s|Sports 0|1st offer 0 = any non alphabetic character Thank you. ...

Sql Server Collation

The book I am reading says that SQL Server supports two kinds of character data types—regular and Unicode. Regular data types include CHAR and VARCHAR, and Unicode data types include NCHAR and NVARCHAR. The difference is that regular characters use one byte of storage for each character, while Unicode characters require two bytes per ...

Trick Question; Showing 'nr of results' of MySql search

I have a classifieds website, and users can search ads. The results are displayed in three tabs on top of the page. These three are "All", "Private", and "Company". Each tab has a nr attached to it, which represents the nr of ads found in that tab. So for example: All Private Company 5 3 2 All is just ...

Informix apostrophe SQL error

I get [Informix][Informix ODBC Driver][Informix]A syntax error has occurred when running the query below. When I remove the double apostrophes the query executes successfully. Everything I can find by Googling tells me I'm doing the right thing. Seven years ago I used Informix without this sort of problem so I think I've forgotten someth...

How do i call a shell app from SQL storedprocedure?

Im trying to call a notepad or calculator from a stored procedure. can anyone help? ...

Subselect Column Invalid issue

I have a sql issue with column names in a subselect im guessing its because it has yet to be assigned that name but I cannot work out how to rearange it. select Distinct Captains.Name, Captains.Team, (select count(Winners.Name) from (select HomeTeamCaptain As Name from fixture where fixture.HomeTeamCaptain = Captains.Name And fixture.ma...

Simple query throwing an SQL syntax error

I've got a simple SQL query that keeps throwing an SQL syntax error. It looks like this: $sql = "SELECT COUNT(*) AS TOTAL FROM PRODUCT WHERE ID_PRODUCT = ".$id; $result = mysql_query($sql) or die(mysql_error()); Which throws : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version...

C#: Convert String to DBType.AnsiStringFixedLength

Hi, I have a stored procedure. One of its input parameters is expecting a char(8). I try to convert a string "AAA" to this particular parameter type, which is a DBType.AnsiStringFixedLength. object v = Convert.ChangeType("AAA", param.DbType.GetTypeCode()); // param is AnsiStringFixedLength However, all I get is an exception: Input ...

Is SQL GROUP BY a design flaw?

Why does SQL require that I specify on which attributes to group. Why can't it just use all non-aggregates. If an attribute is not aggregated and is not in the GROUP BY clause then nondeterministic choice would be the only option assuming tuples are unordered (mysql kind of does this) and that is a huge gotcha. AFAIK Postgresql requires ...

Comparing stored procedure performance ex and new version

I did create two new indexes on the tables that are used on a the sp. The new results shows that on the part of problematic joins, the scans are converted to seek. I think seek is better rather than scan operations. On the other hand, the time takes more or less the same duration as it was without new indexes. So clearly, how can i get...

Select from SQLite with Qt

I try to deal with SQLite database on Qt 4.5.3 on Linux. I've already created DB with another program and it looks like this: screenshot Then, I try to perform select on Qt: db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(filename); // Here is FULL path to the database. I've checked it twice :) bool ok = db.open(); qDebug...

Partitioning of the database in SQL Server 2005

My project modules are organized in such a way that I have to maintain following Database structure. I've 5 schemas, each containing 20 to 50 tables. Each schema is associated with one module of the project. All the tables that are used within more than one modules are kept in "COMMON" schema. Each module takes 2 to 5 months to finish....

Calculate Date from the Difference in Weeks

Example today's @date = 2010-02-22 14:17:19.393 Number @weeks = 2 Equation I am looking for is (@date - @weeks = 2010-02-08 14:17:19.393) ...

Database design for summarized data

I have a new table I'm going to add to a bunch of other summarized data, basically to take some of the load off by calculating weekly avgs. My question is whether I would be better off with one model over the other. One model with days of the week as a column with an additional column for price or another model as a series of fields ...