sql

Is there a tool that will show diagrams of my SQL database in real-time?

I've created some diagrams of SQL tables using the "Reverse Engineer" feature of Microsoft Office Visio. I like being able to visualize my relational databases in this manner. However, what I get is just a static document that I can print, e-mail to colleagues, and click widgets on. Earlier this year, I saw at a demo that the new vers...

Get the First And Last Date of Next Month in MySQL

How can I get the first and last day of next month to be used in the where clause? ...

Syntax error trying to create an sql table from Java

I want to create a table and this table's name will be inserted from a textfield. However when I run the query it's giving me an error, any help on this one? I'll paste the code here: public boolean CreateTable() { TableNumber = jTextField4.getText(); try { String password = null; String s = "CREATE TABLE '"+Tab...

Removing part of a string in PHP

I'm trying to take a query: SHOW TABLES; which will display a bunch of tables with the chat_ prefix. I want to remove the chat_ prefix from the string, format the variable (with a link), and display it. How is this accomplished? ...

How to run SQL that contains bind variables in the ODT Query Window?

How do you run SQL that contains one or more bind variables in the Oracle Developer Tools for Visual Studio Query Window? For example, the following works fine in SQL*Plus: variable x NUMBER; BEGIN :x := 0; END; / SELECT 1 FROM DUAL WHERE :x <> 1; When executed in the ODT Query Window, the following exception is raised in the Query...

How to use avg function?

I'm new at php and mysql stuff and i'm trying to use an avg function but i don't know how to. I'm trying to do something like this: mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die ("Did not connect to $database"); mysql_query("AVG(column1) FROM table1 ") or die(mysql_error()); mysql_close(); echo AV...

Usage of oracle function sys connect by path

We have a problem that it seens not supported in oracle 10g what could be the cause? ...

Help with Oracle SQL Count function! =)

Hi guys.. The question I'm struggling with is this: I have a list of helicopter names in different charters and I need to find out WHICH helicopter has the least amount of charters booked. Once I find that out I need to ONLY display the one that has the least. I so far have this: SELECT Helicopter_Name , COUNT (Distinct Chart...

How to design a generic database whose layout may change over time?

Here's a tricky one - how do I programatically create and interrogate a database whose contents I can't really foresee? I am implementing a generic input form system. The user can create PHP forms with a WYSIWYG layout and use them for any purpose he wishes. He can also query the input. So, we have three stages: a form is designed an...

How do you get average of sums in SQL (multi-level aggregation)?

I have a simplified table xx as follows: rdate date rtime time rid integer rsub integer rval integer primary key on (rdate,rtime,rid,rsub) and I want to get the average (across all times) of the sums (across all ids) of the values. By way of a sample table, I have (with consecutive identical values blanked out for readabilit...

CakePHP adding columns to a table

I have a Profile model/controller in my cake app as well as an index.ctp view in /views/profiles. Now, when I go to add a column to my table that is already filled with data, and then add the corresponding code to the view to pick up this column's data, it just gives me an empty result. My model: <?php class Profile extends App...

help optimize sql query

I have tracking table tbl_track with id, session_id, created_date fields I need count unique session_id for one day here what i got: select count(0) from ( select distinct session_id from tbl_track where created_date between getdate()-1 and getdate() group by session_id )tbl im feeling that it could be ...

Skip first letters of all values returned from a sql server database

Hi, as topic says, I don't want to return the first two letters in the return values just an example: select companyname from companies returns companyX Can I write a query that returns panyX instead? Thanks in advance ...

create database on sqlite3 (foreign key issues)

Hi everyone I have 3 tables: CREATE TABLE Destination (DestinationID INTEGER NOT NULL PRIMARY KEY, Destination TEXT NOT NULL, NoGoing INTEGER NOT NULL); CREATE TABLE User (UserID INTEGER NOT NULL PRIMARY KEY, UserName TEXT NOT NULL); CREATE TABLE Query (UserID INT...

SQL Where clause in ORACLE

How can i use the END_DATE/START_DATE from the first sub select in the second subselect?, the provided values are only examples. (06/01/2010). SELECT "PROJECT"."ID", "PROJECT"."CLIENT", "PROJECT"."NAME", "PROJECT"."STATE", "PROJECT"."EARLIEST_START", "PROJECT"."LATEST_END", "PROJECT"...

How to not add values from Join

SELECT ... FROM [Rep_GroupNode] C left join (SELECT .... if I'm using left join only for compare some thing due selecting how to not add(double) values from join ? ...

i have problem to get new inserted columnID using sql

hi I have an identity column defined as int in sql . I use SCPOE_IDENTITY () to get the new inserted column id. this is sample of my code: Dim sql As String = "insert into infoHotel (nameHotel, knownAs1, knownAs2, knownAs3, knownAs4, streetAddress) values (N" & _ FormatSqlParam(hotel) & ",N"...

What should I use to increase performance. View/Query/Temporary Table

I want to know the performance of using Views, Temp Tables and Direct Queries Usage in a Stored Procedure. I have a table that gets created every time when a trigger gets fired. I know this trigger will be fired very rare and only once at the time of setup. Now I have to use that created table from triggers at many places for fetching ...

Using NVL function in SQL, please help!

I'm needing to select first and last name in a table which is working fine in the following SQL, but the part that isn't working is the NVL function. The file should show all pilots at a company that fly helicopters and IF they don't have a licence the field HT_NAME should come up as 'N/A' and the field for end hours flown should be 0. I...

Where Does Temporary Tables Gets stored in sql server.

Where does temporary tables gets stored in database. I want to drop a temporary table if it already exists. I can do this for securable table by querying at information schema but i done know where temporary tables are stored ...