i have table country and having country name and country code,
i have customer table having countomer mobile number like customer_mobile field values like 0044-123456798 ,
0024-582654753 , 012-52686145 ,
i want to populate my country oce into combo,
that country name should in customer table which country code count is high that country name should come in the
dropdown list top ,
How to write the join query...
Thanks
i have interest rate and amount in a table where interest rate are ranged in different values
like 4.5,4.6,5.2,5.6 etc.
i want to get sum of amounts classified by interest rate where interest rate will be separated
by .25.
for example all amount having interest rate 1.25,1.3,1.4 will be in one group
and 1.5,1.67,1.9 will be in another group
how can i write the query?
I need to write a query that creates a view that calculates the total cost of each sale, by considering quantity and price of each bought item. The view should return the debit and total cost.
In the answer each debit-number should only occur once.
Thanks in advance
Table ITEM:
ID NAME PRICE
118 Jeans 100
120 Towel 20
127 Shirt 55
Table DEBIT:
DEBIT ITEM Quantity
100581 118 5
100581 120 1
100586 127 5
I need to retrieve data from within a specific date range.Anybody can help me to create a query to getting the information within date range 12-12-2009 to 12-15-2009 from a mysql table.(including 12 and 15)
I'm writing an InfoPath web form, using C# code behind. The form is a holiday request, after the user inputs the start and end dates I want the code to query a bank-holiday sharepoint list and count occurrences between the dates.
I've added the sharepoint list as a second datasource however I'm now stuck. Any ideas?
Hi all
Say I got 3 entities: Business, Employee and Payment. A payment has a foreign key to an Employee, while the Employee has an foreign key to a business.
Now, I want to create a query which gives me all payments for a given business. I really don't have a clue about how to do this - I guess I want something like:
mySession.CreateCriteria<Payment>()
.Add(Criterion.Expression.Eq(/* Employee_FK => Employee.Business_FK == BusinessID */);
Any help would be greatly appreciated :)
Here's the query:
INSERT INTO jobemails (jobid, to, subject, message, headers, datesent) VALUES ('340', '[email protected]', 'We\'ve received your request for a photo shoot called \'another\'.', 'message', 'headers', '2010-04-22 15:55:06')
The datatypes are all correct, it always fails at the subject, so it must be how I'm escaping the values, I assume.
I'm sure one of you will see my idiot mistake right away. A little help?
hi!
i have 3 tables A,B and C.
table A has column employee_name,id
table B is the main table and has columns id,os version.
table c has the columns id,package id and package version.
i want to query the count of employee_name where the id of table a and c are matched with id of table b(which is the main table).
i should also get the names of employees grouped by the os version they have and also the package version.
I have a column that contains links. The problem is that the titles of the links are in the same column, so it looks like this:
linktitle|-|linkurl
I want link title and linkurl in separate columns.
I've created a new column for the urls, so I'm looking for a way to extract them and update the linkurl column with them. Is there any clever way to construct a query that does this?
So I have written a query that will grab an order (this is for an ecommerce type site), and from that order id it will get all order items (ecom_order_items), print options (c_print_options) and images (images). The eoi_p_id is currently a foreign key from the images table.
This works fine and the query is:
SELECT
eoi_parentid, eoi_p_id, eoi_po_id, eoi_quantity,
i_id, i_parentid,
po_name, po_price
FROM ecom_order_items, images, c_print_options WHERE eoi_parentid = '1' AND i_id = eoi_p_id AND po_id = eoi_po_id;
The above would grab all the stuff I need for order #1
Now to complicate things I added an extra table (ecom_products), which needs to act in a similar way to the images table. The eoi_p_id can also point at a foreign key in this table too. I have added an extra field 'eoi_type' which will either have the value 'image', or 'product'.
Now items in the order could be made up of a mix of items from images or ecom_products. Whatever I try it either ends up with too many records, wont actually output any with eoi_type = 'product', and just generally wont work. Any ideas on how to achieve what I am after? Can provide SQL samples if needed?
SELECT
eoi_id, eoi_parentid, eoi_p_id, eoi_po_id, eoi_po_id_2, eoi_quantity, eoi_type,
i_id, i_parentid,
po_name, po_price, po_id,
ep_id
FROM ecom_order_items, images, c_print_options, ecom_products WHERE eoi_parentid = '9' AND i_id = eoi_p_id AND po_id = eoi_po_id
The above outputs duplicate rows and doesnt work as expected. Am I going about this the wrong way? Should I have seperate foreign key fields for the eoi_p_id depending it its an image or a product?
Should I be using JOINs?
Here is a mysql explain of the tables in question
ecom_products
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| ep_id | int(8) | NO | PRI | NULL | auto_increment |
| ep_title | varchar(255) | NO | | NULL | |
| ep_link | text | NO | | NULL | |
| ep_desc | text | NO | | NULL | |
| ep_imgdrop | text | NO | | NULL | |
| ep_price | decimal(6,2) | NO | | NULL | |
| ep_category | varchar(255) | NO | | NULL | |
| ep_hide | tinyint(1) | NO | | 0 | |
| ep_featured | tinyint(1) | NO | | 0 | |
+-------------+--------------+------+-----+---------+----------------+
ecom_order_items
+--------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+-------------+------+-----+---------+----------------+
| eoi_id | int(8) | NO | PRI | NULL | auto_increment |
| eoi_parentid | int(8) | NO | | NULL | |
| eoi_type | varchar(32) | NO | | NULL | |
| eoi_p_id | int(8) | NO | | NULL | |
| eoi_po_id | int(8) | NO | | NULL | |
| eoi_quantity | int(4) | NO | | NULL | |
+--------------+-------------+------+-----+---------+----------------+
c_print_options
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| po_id | int(8) | NO | PRI | NULL | auto_increment |
| po_name | varchar(255) | NO | | NULL | |
| po_price | decimal(6,2) | NO | | NULL | |
+------------+--------------+------+-----+---------+----------------+
images
+--------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+----------------+
| i_id | int(8) | NO | PRI | NULL | auto_increment |
| i_filename | varchar(255) | NO | | NULL | |
| i_data | longtext | NO | | NULL | |
| i_parentid | int(8) | NO | | NULL | |
+--------------+--------------+------+-----+---------+----------------+
ID
NAME
AMT
1
Name1
1000
2
Name2
500
3
Name3
3000
4
Name1
5000
5
Name2
2000
6
Name1
3000
consider above table as sample.
am having a problem in my sql query, Am using like this.
Select name,amt from sample where amt between 1000 and 5000
it returns all the values in the table between 1000 and 5000, instead
I want to get maximum amount record for each name
i.e.,
3 name3 3000
4 name1 5000
5 name2 2000
hello, I am Running a oracle query, it seems to work except that it returns 4 dupes of each result.
here is the code:
Select * from (Select a.*, rownum rnum From (SELECT NEW_USER.*, NEW_EHS_QUIZ_COMPLETE.datetime FROM NEW_USER, NEW_EHS_QUIZ_COMPLETE WHERE EXISTS(select * from NEW_EHS_QUIZ_COMPLETE where NEW_USER.id=NEW_EHS_QUIZ_COMPLETE.USER_ID) ORDER by last_name ASC ) a where rownum <= #pgtop# ) where rnum >= #pgbot#
does anyone know why this isnt working properly? thanks in advance.
hi
i have this table:
id|date
1 | 10/11/2009
2 | 13/11/2009
1 | 20/12/2009
3 | 21/12/2009
1 | 30/12/2009
if i stand on the last record (id=1) and i need to see the last date where
id=1 is appear -- will show me: 1 | 20/12/2009
what query will do it ?
thank's in advance
Hi,
Is there a way to get the insert statements for a table via some query in MySql?
for ex: if the table name is Cards,which has 5 rows, i need to get the insert statements for that particular table.
Thanks.
i need to get a query where the elements are displayed in case the first letter is E (the word is electronics).. i have tried with the following :
mysql_query("select * from nested_category where name like '[A-F]%'");
hi
i have 4000 records, and i need to pick randomize 500 records.
i need that 500 records will insert to GoodTable
and the rest 3500 records will insert to BadTable
how to do it using sql-server 2008 query ?
thank's in advance
Hi ,
in my database i have phone numbers with country code , which look somthing like
0044-123456
0044-123456
0014-123456
0014-123456
0024-123456
0024-123456
0034-123456
0044-123456
0044-123456
0024-123456
0034-123456
084-123456
084-123456
i want to total up the numbers by country, something like this output
0044 (2)
0024 (2)
0034 (1)
084 (2)
064 (5)
Is it possible to do this with a SQL query?
Can any one please let me know the best way to use IF statement in mysql query to show if the "email" field is NULL then it should show as "no email"...
Postcode Telephone Email
----------------------------------------------------------
BS20 0QN 1275373088 no email
BS20 0QN 1275373088 no email
PO9 4HG 023 92474208 [email protected]
SO43 7DS 07801 715200 [email protected]
----------------------------------------------------------
select p.id,p.title,p.slug,p.content,
(select url from gallery
where postid=p.id limit 1) as url,
t.name
from posts as p
inner join termrel as tr on (tr.object = p.id)
inner join termtax as tx on (tx.id = tr.termtax_id)
inner join terms as t on (t.id = tx.term_id)
where tx.taxonomy_id=3 and p.post_status is null
order by t.name asc
This query took about 0.2407s to execute. How to make it fast?
I am having trouble figuring our how I can get results only when products.published, product_types.published, and product_cats.published = 1 but my query isn't working. Please help:
SELECT
`products`.`title`,
`products`.`menu_id`,
`products`.`short_description`,
`products`.`datasheet_icon`,
`products`.`datasheet`,
`products`.`ordering`,
`products`.`product_type_id`,
CASE WHEN CHAR_LENGTH(`products`.`alias`)
THEN CONCAT_WS(':', `products`.`id`, `products`.`alias`)
ELSE `products`.`id`
END AS slug
FROM
`products`,
`product_cats`,
`product_types`
WHERE
`products`.published=1 AND
`product_cats`.published=1 AND
`product_types`.published=1 AND
`products`.`product_cat_id`='42' AND
`product_types`.`id` IN (1,40,48,49,50)
GROUP BY `products`.`id`
ORDER BY `product_types`.`ordering`, `products`.`ordering`
I am very new to Oracle, and trying to restore a oracle 8i database on win 2000 server.
I have one week old database backup (backup taken with exp command), and i want to restore it now.
Now I am unable to login through sqlplus (got shutdown in progress error)
I have a backup and i want to restore it, but oracle is not starting at all, and 'imp' command is failing.
I started sqlplus / as sysdba and following is the log of what i am trying to do. Can some one guide me further.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 143423516 bytes
Fixed Size 75804 bytes
Variable Size 58105856 bytes
Database Buffers 85164032 bytes
Redo Buffers 77824 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 143423516 bytes
Fixed Size 75804 bytes
Variable Size 58105856 bytes
Database Buffers 85164032 bytes
Redo Buffers 77824 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01245: offline file 1 will be lost if RESETLOGS is done
ORA-01110: data file 1: 'C:\ORACLE\ORADATA\ABCD\SYSTEM01.DBF'
I am using Fedora 8 and Oracle 10g Express Edition.
Every time I start my fedora I have to click on start database.
How can I add startdb.sh to startup so that it automatically executes when Fedora starts?
I have tried adding the path to /etc/rc.d/rc.local but it still doesn't work.
./usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/startdb.sh
I have even tried to add this script in /etc/init.d/oracle
#!/bin/bash
#
# Run-level Startup script for the Oracle Instance and Listener
#
# chkconfig: 345 91 19
# description: Startup/Shutdown Oracle listener and instance
ORA_HOME="/u01/app/oracle/product/9.2.0.1.0"
ORA_OWNR="oracle"
# if the executables do not exist -- display error
if [ ! -f $ORA_HOME/bin/dbstart -o ! -d $ORA_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
# depending on parameter -- startup, shutdown, restart
# of the instance and listener or usage display
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl start"
su - $ORA_OWNR -c $ORA_HOME/bin/dbstart
touch /var/lock/subsys/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su - $ORA_OWNR -c "$ORA_HOME/bin/lsnrctl stop"
su - $ORA_OWNR -c $ORA_HOME/bin/dbshut
rm -f /var/lock/subsys/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 start|stop|restart|reload"
exit 1
esac
exit 0
and even this doesn't work.
startdb.sh is located at /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/config/scripts/startdb.sh
Thanks.
I am very new to Oracle, and trying to restore a oracle 8i database on win 2000 server.
I have one week old database backup (backup taken with exp command), and i want to restore it now.
Now I am unable to login through sqlplus (got shutdown in progress error)
I have a backup and i want to restore it, but oracle is not starting at all, and 'imp' command is failing.
I started sqlplus / as sysdba and following is the log of what i am trying to do. Can some one guide me further.
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 143423516 bytes
Fixed Size 75804 bytes
Variable Size 58105856 bytes
Database Buffers 85164032 bytes
Redo Buffers 77824 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 143423516 bytes
Fixed Size 75804 bytes
Variable Size 58105856 bytes
Database Buffers 85164032 bytes
Redo Buffers 77824 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-01245: offline file 1 will be lost if RESETLOGS is done
ORA-01110: data file 1: 'C:\ORACLE\ORADATA\ABCD\SYSTEM01.DBF'