Suppose we have 20 columns in a table and I want to return 19 of them.
How can I do that ?
select *
will give me all of them but I want only 19.
Is there a good solution for that situation ? something like
select * - [columnName]
?!?
...
When doing:
DELETE FROM `jobs` WHERE `job_id` =1 LIMIT 1
It errors:
#1451 - Cannot delete or update a parent row: a foreign key constraint fails (paymesomething.advertisers, CONSTRAINT advertisers_ibfk_1 FOREIGN KEY (advertiser_id) REFERENCES jobs (advertiser_id))
Here are my tables:
CREATE TABLE IF NOT EXISTS `advertisers` (
`a...
I am firing a query which returns minimum 1000 rows containing name, amount in order amount desc. I want the index of some name from that array, I don't know how to do it?
As I am using Ruby, I use arr.index(name)+1 method which returns the index properly.
But I want some MySQL query which gives me only numbers for that particular name....
Dear guys
I insert data from a typed dataset into my MSSQL database by using SqlBuldCopy class:
foreach (DataTable dt in ds.Tables)
{
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(conn))
{
bulkCopy.DestinationTableName = "dbo." + dt.TableName + "_neu";
try
{
bulkCopy.WriteToServer(dt);
...
i want to develop a procedure for following scenario.
I have one source, one target and one error table. Target and Error tables have all fields that are present in source tables. But the data type of all fields for error table are varchar. Error table don't have integrity, foreign key and other constraints.
Error table also have t...
When I have two sql-files, one of them in a sub-directory
main_test.sql
sub/sub_test.sql
and sub_test.sqlcalls @../main_test.sql (or @@../main_test.sql) then this works fine when executing it from the sub-directory
sub> sqlplus xxx @ sub_test.sql
But when I call
sub> cd ..
> sqlplus xxx @ sub/sub_test.sql
this results in
SP2-03...
Hello!
I try to make an "advanced" search field for users. (the users have 5-8 field to short the search list..)
I think i have to build the query depending on which posted field is not empty.
This is my original query, but with this, i got all the row from table..
$query = "select * from MYTABLE where FIELD1 LIKE '%$sample1%' OR FIE...
I've just started using SQLite and I want to write all my application data to a file, not knowing if the file exists already; with 'normal' files, this is straightforward, but with SQLite I can't create a table if it already exists, and I can't insert a row if the primary key already exists.
I basically want to do something like "CREATE...
How can i know which sql statement fired through trigger for select, insert, update and delete on table?
Thanks,
Paresh Prajapati
http:\paresh-sqldba.blogspot.com
...
In SQL (MSSQL, Oracle, etc., whatever), when joining tables, what is the gain from adding a filter to the JOIN statement instead of having it in the WHERE clause?
i.e.
SELECT * FROM X INNER JOIN Y ON X.A = Y.A WHERE X.B = 'SOMETHING'
versus
SELECT * FROM X INNER JOIN Y ON X.A = Y.A AND X.B = 'SOMETHING'
I realize that this does no...
Hi Folks,
following problem, i want to create an view in Oracle wich calculates an "utilization rate in percent".
AS SELECT
sw.SWITCH_ID,
sw.ASSET_ID,
sw.SYSTEMNAME,
sw.MAX_INSTALLABLE_PORTS,
sw.INSTALLED_PORTS,
sw.USED_PORTS,
(sw.INSTALLED_PORTS/sw.MAX_INSTALLABLE_PORTS)*100 AS UTIL_INSTALLED_PORTS,
sw.RES_INFRASTRUCTU...
Hello,
Lets say I have 2 tables: blog_posts and categories. Each blog post belongs to only ONE category, so there is basically a foreign key between the 2 tables here.
I would like to retrieve the 2 lasts posts from each category, is it possible to achieve this in a single request?
GROUP BY would group everything and leave me with only...
I'd like to thank another Stackoverflow member for helping with this code. I'm having trouble setting up this code to export the text in the format that i'd like, any tips would be great.
Scenario: I have a listBox being populated from an SQL query. That listBox has a button to populate listBox2. Columns name is whatever columns pic...
How to count rows with distinct values on any of the three columns: col1, col2, col3?
...
I have a crystal report that gets its data from one stored procedure, this works fine and I have a nice grouped report with this data, showing information about a particular report,
However, this report also needs to have a number of graphs in the footer. These graphs draw their data from a different table, and so a different stored pro...
hi
my code is this,
$query = "SELECT * FROM `cars` WHERE (color LIKE '%". $key ."%' OR name LIKE '%". $key ."%') AND enabled = 'yes' ORDER BY `ID`";
database is like this
ID color name enabled
---- ------ -------- ---------
1 red red car yes
2 blue blue car yes
3 ...
I use prepareStatement() when the id is a key of my SQL table and it will be created by SQL and I want to use this statement :(what should I write instead of X in the first column of SQL table(reminder:SQL create it automatically)
File file = new File(pathFile);
FileInputStream input = new FileInputStream(file);
...
We're in the process of designing a tiny database that will contain data regarding our software's usage.
So in our programs/websites we will call a little service that logs some data regarding the session and the action performed. This way we can see what parts of our programs are heavily used, what the most common usage scenarios are et...
I have an EMPLOYEE table in a SQL Server 2008 database which stores information for employees (~80,000+) many times for each year. For instance, there could by 10 different instances of each employees data for different years.
I'm reporting on this data via a web app, and wanted to report mostly with queries directly against the EMPLOY...
CREATE TABLE Landmark
(
Indexc NUMBER
Birth DATE
Address VARCHAR2(50 BYTE)
City VARCHAR2(30 BYTE)
State CHAR(2 BYTE)
Zip VARCHAR2(15 BYTE)
...
Other properties
)
ALTER TABLE Landmark ADD (
CONSTRAINT Landmark_PK PRIMARY KEY (Indexc, Birth));
CREATE TABLE MapPoint
(
Indexc NUMBER
Longitude FLOAT(126)...