sql

100+ tables to joined

Hi guys, I was wondering if anyone ever had a change to measure how a would 100 joined tables perform? Each table would have an ID column with primary index and all table are 1:1 related. It is a common problem within many data entry applications where we need to collect 1000+ data points. One solution would be to have one big table w...

Is a primary key automatically indexed?

Is it true that in MySQL the primary key is automatically indexed? ...

How do you sort php and sql arrays?

How can I sort this array by city or by id in descending order? if ($num > 0 ) { $i=0; while ($i < $num) { $city = mysql_result($result,$i,"city"); $state = mysql_result($result,$i,"state"); $id = mysql_result($result,$i,"id"); echo "$city"; echo "$state"; ++$i; } } else { echo "No results."; } ?> ...

Only show certain items in a mysql database using php and time()

Is there a way to only show the items that are older than a certain date in a php mysql array? I'm using this query method and sorting by lastpost_cl: $query="SELECT * FROM properties ORDER BY lastpost_cl"; $result=mysql_query($query); $num = mysql_num_rows ($result); mysql_close(); and I was thinking the way of checking the time wou...

subquery factoring questions.

Hi, Please explain. a) "subquery factoring" is used to replace a non-correlated subquery. What about correlated subquery? Is there any way to move a correlated sub-query to 'WITH' clause section? b) are "subquery" "subquery factoring" executed exactly once? c) "subquery" vs "subquery factoring" which one is better Thank you. ...

displaying sql exception in JSF

I was wondering how would I be able to show SQL errors generated during update, delete, select * etc in JSF. Any help would be appreciated. ...

How to write a complex reporting system in a maintainable way AND have debugging capabilities on the production site?

Here is the scenario: I am currently working on a legacy reporting system for a company which collects data from sensors. The database (SQL-Server 2005) is fairly big (ca. 500 GB) with hundreds of MB’s being added every day. The system runs a series of nightly jobs in order to aggregate and transform the newly added data into a staging ...

MySQL: INNER JOIN

I have a table which contains UserId & his Friends Id like: ---------------------------------------------- UserFriendsId | UserId | FriendId ---------------------------------------------- 1 1 2 ---------------------------------------------- 2 1 3 ---------...

I need some help optimizing my database schema

Here's a layout of my data: Heading 1: Sub heading Sub heading Sub heading Sub heading Sub heading Heading 2: Sub heading Sub heading Sub heading Sub heading Sub heading Heading 3: Sub heading Sub heading Sub heading Sub heading Sub heading Heading 4: Sub heading Sub heading Sub h...

Execute Statements in a Transaction - Sql Server 2005

hi, i need to update a database where some of the table have changed (columns have been added). I want to perform this action in a proper transaction. If the code executes without any problem then i will commit the changes otherwise i will rollback the database back to its original state. I want to do something like this: BEGIN TRANSA...

How to organize SQL script files & folders

We have an Oracle 10g database (a huge one) in our company, and I provide employees with data upon their requests. My problem is, I save almost every SQL query I wrote, and now my list has grown too long. I want to organize and rename these .sql files so that I can find the one I want easily. At the moment, I'm using some folders named a...

Error 18456. State 6 "Attempting to use an NT account name with SQL Server Authentication."

2010-05-06 17:21:22.30 Logon Error: 18456, Severity: 14, State: 6. 2010-05-06 17:21:22.30 Logon Login failed for user . Reason: Attempting to use an NT account name with SQL Server Authentication. [CLIENT: ] The authentication mode is "Mixed". And its MS SQL Server 2008. What might be the issue? Do you think the user name w...

How to optimize an update SQL that runs on a Oracle table with 700M rows

UPDATE [TABLE] SET [FIELD]=0 WHERE [FIELD] IS NULL [TABLE] is an Oracle database table with more than 700 million rows. I cancelled the SQL execution after it had been running for 6 hours. Is there any SQL hint that could improve performance? Or any other solution to speed that up? EDIT: This query will be run once and then never aga...

Setting a variable for a Z SQL method

In Plone I have a Z SQL methood: SELECT [aapp_qtitle] ,[aapp_mtitle] ,[aapp_sdate] ,[aapp_duration] FROM [AAPP].[dbo].[M_PageBodyElement] where [aapp_id]=<dtml-sqlvar aapp_id type=int> How can I set the value of aapp_id in my Plone page code? OK thanks Matthew what's the exact template code? I've tried: <p tal:def...

Spaced repetition (SRS) for learning

A client has asked me to add a simple spaced repeition algorithm (SRS) for an onlinebased learning site. But before throwing my self into it, I'd like to discuss it with the community. Basically the site asks the user a bunch of questions (by automatically selecting say 10 out of 100 total questions from a database), and the user gives ...

Is there an OR filter? - Django

Hi folks, is there any way of doing the following Unicorn.objects.or_filter(magical=True).or_filter(unicorn_length=15).or_filter(skin_color='White').or_filter(skin_color='Blue') where or_filter stands for an isolated match I remember using something similar but cannot find the function anymore! Help would be great! Thanks :) ...

Write a file header with select into outfile directive ?

Hi, I need to find a way to insert a file header (not column header) and dump my data after that. How would you do that ? Regards, ...

error handling in asp.net

Hi How can i pass the different types of errors from Data access layer to presentation layer? suppose if we take the northwind database scenario I want to delete the customer, so i selected one customer in ui and clicked the "delete" button.It internally calls the "delete" in data access layer. The prerequisite for deleting the cus...

In-Proc DB supporting sprocs

Is there an in process database, like SQLite or Sql Server Compact Edition, that supports stored procedures? ...

Recursive only 2 level records using common sql

I have an Employee table, it's a self-referencing table, with managerId refers to primary key empID. I want to find 2 level records by a given empId. For example: if given empId=5, if empId=5 has children records, display them, as well as the children in children records. The database is SQL Server 2005. update: I wanna a full project...