给parkway的store list

select storeId, storeName, unit,vendor_no as VendorID, payee, contact, telephone, address, bank_name
from parkway.store
where isActive = 'Y'
order by storeName asc




#FOR MG
select storeId, storeName,category, unit, isActive, is_still_vms_available
from store
where storeId > 1000
order by storeName asc

更新campaign需要修改的地方

voucher #type

voucher_action #remarks

voucher_campaign_issue #campaign_id

voucher_campaign_issue_request #campaign_id

voucher_request_approve #request_remarks

voucher_receipt_numbers #campaign_id,receipt_no

 

SELECT *
FROM voucher
WHERE CONCAT(prefix, voucher_text) IN ('JP500004176','JP500004177')
#42176,42177

SELECT *
FROM voucher_action
WHERE voucher_id IN (42176,42177)
AND action_id = 30

SELECT *
FROM voucher_campaign_issue
WHERE voucher_id IN(42176,42177)
SELECT *
FROM voucher_campaign_issue_request
WHERE request_id IN (11591)

SELECT * FROM voucher_request_approve WHERE request_id IN (11591) SELECT * FROM voucher_receipt_numbers where voucher_ids like 'B176,42177%'

 

select e.prefix, e.suffix, length(f.voucher_text) AS len, e.start_no, e.end_no, f.voucher_value
  , e.total_vouchers, e.total_value, d.type_desc, h.user_name, a.request_time, a.`request_remarks`, d.type_name
  from jurongpoint.voucher_request_approve a, jurongpoint.voucher_campaign_issue_request b, jurongpoint.voucher_campaign c
  ,jurongpoint.voucher_lkup_type d, jurongpoint.voucher_batch_no_section e, jurongpoint.voucher f, evo_central_config.customer_user h
  where `request_time` between '2014-08-01 00:00:00' and '2014-12-05 23:59:59'
  and a.`from_stock` = '35' and a.`to_stock` = '50'
  and a.request_id = b.request_id
  and b.campaign_id = c.campaign_id
  and c.type_id = d.type_id
  and e.batch_id = a.batch_id
  and e.prefix = f.prefix and e.suffix = f.suffix and e.start_no = f.voucher_no
  and a.request_user = h.user_id
  and d.type_name = 'partner'
  order by a.request_time desc

mysql update使用要update的字段查询

CREATE TABLE tmp_voucher
SELECT a.voucher_id
FROM voucher a, voucher_action b
WHERE a.stock_id = 50 AND a.status_id != 40 AND a.voucher_id = b.voucher_id AND b.action_id = 60
GROUP BY a.voucher_id

UPDATE voucher a, tmp_voucher b SET a.stock_id = 60
WHERE a.voucher_id = b.voucher_id

drop table tmp_voucher;

 

使用以上方法解决,

因为mysql不能直接update查询子句内的字段否则会报错“you can't specify target table 'xxxx' for update in from CLAUSE”

Balsamiq Mockups 注册码

这个是测试成功的

Organization name: Rick Dong

Serial Key: eNrzzU/OLi0odswsqgnKTM5WcMnPS1eoMTQyMjexMDQyAIEa5xpDAA8pDD8=

——————————————————————————————————————————

License Name:www.bonashen.com

License Key for All Product

 

MockupsFogBugz’s key:

eJzzzU/OLi0odstPdypNr6opLy/XS8rPSyzOSM3TS87PrTE0BkEgsjQxN6xxrnECSuoFA2UBZAsT7A==

 

MockupsConfluence’s key:

eJzzzU/OLi0ods7PS8spTc1LTq0pLy/XS8rPSyzOSM3TS87PrTE0BkEgsjSxMK9xrnECSuoFA2UBsI0VQQ==

 

MockupsCompanion’s key:

eJzzzU/OLi0ods7PLUjMy8zPqykvL9dLys9LLM5IzdNLzs+tMTQGQSCyNLEwr3GucQJK6gUDZQGZ2RTj

 

MockupsAir’s key:

eJzzzU/OLi0odswsqikvL9dLys9LLM5IzdNLzs+tMTQGQSCyNLGwqHGucQJK6gUDZQEMMRJc

 

MockupsJIRA’s key:

eJzzzU/OLi0o9vIMcqwpLy/XS8rPSyzOSM3TS87PrTE0BkEgsjSxsKhxrnECSuoFA2UBEaMSZg==

 

MockupsXWiki’s key:

eJzzzU/OLi0ojgjPzM6sKS8v10vKz0sszkjN00vOz60xNAZBILI0sbCsca5xAkrqBQNlATh7Ey0=

 

 

 

Extend Voucher’s SQL

SELECT *
FROM voucher
WHERE CONCAT(prefix, LPAD(voucher_no,6,'00')) IN ('CR005496','CR000032','CR003930','CR007992','CR002811','CR002812');

UPDATE voucher SET expiry_time='2014-08-08 23:59:59', extend_cnt=1, is_expired='N' where voucher_id in (262032,264811,264812,265930,267496,269992);

INSERT INTO `voucher_action` (`id`, `voucher_id`, `action_id`, `action_time`, `user_id`, `comment`, `ct_user`) 
SELECT NULL,voucher_id,11,'2014-08-12 10:00:00', 10, 'Manual extend to 8 Aug.', NULL FROM voucher
WHERE voucher_id IN ('262032','264811','264812','265930','267496','269992');

 

Voucher2:

UPDATE voucher SET type_id=0,status_id=1,stock_id=1,expiry_date= NULL WHERE CONCAT(prefix, LPAD(voucher_no,7,'0')) IN ('JP500001598','JP500001599','JP500001600','JP500001498');


delete from voucher_action where voucher_id in (15498,15598,15599,15600) and action_id = 30  
delete from voucher_campaign_issue where voucher_id in (15498,15598,15599,15600)             
delete from voucher_campaign_issue_request where request_id in (10541,10543,10542)           
delete from voucher_request_approve where request_id in (10541,10543,10542)                  
delete from voucher_receipt_numbers where receipt_no in ('DS0000993','DS0000995','DS0000994')
UPDATE voucher SET expiry_time=adddate(NOW(),7), extend_cnt=1, is_expired='N' where voucher_id in (75562,75563);

INSERT INTO `voucher_action` (`id`, `voucher_id`, `action_id`, `action_time`, `user_id`, `comment`, `ct_user`) 
SELECT NULL,voucher_id,11,NOW(), 10, 'Manual extend to 7 days.', NULL FROM voucher
WHERE voucher_id IN (75562,75563);

CORP SALE BatchActive 漏掉的更新voucher value SQL

#UPDATE cs_request_relation_group a, cs_request_section b, voucher c
#SET c.voucher_value = a.value
SELECT c.voucher_text, c.voucher_value, a.value
FROM cs_request_relation_group a, cs_request_section b, voucher c
WHERE a.request_id IN (63,64,65) AND b.relation_id = a.relation_id
AND c.prefix=b.prefix AND c.voucher_no BETWEEN b.first_no AND b.last_no

Mysql Concat使用

CONCAT用的已经很多了 今天用到的时候是需要连接多次payment的log,每一次payment一次就记录到同一个field里。而开始的时候我用concat发现没有效果,然后查了一下concat函数才了解到如果concat中间的参数如果有null那么concat出来的结果就是null,解决方法如下:

CONCAT(ifnull($tmp_key,''), '|', '$tmp_val')

MySQL 中集合的差的运算方法【记录待参考】

1. http://www.blogjava.net/rox/archive/2006/09/01/67008.html

MySql只支持Union(并集)集合运算,好像也是4.0以后才有的;
但是对于交集Intersect、差集Except,就没有实现了。
一般的解决方案用in和not in来解决,小量数据还可以,但数据量大了效率就很低了。
其实,可以使用Union来实现另外两种的运算,当然是没有办法的办法。

差集Except:
SELECT ID FROM (
SELECT DISTINCT A.AID AS ID FROM TABLE_A A
UNION ALL
SELECT DISTINCT B.BID AS ID FROM TABLE_B B
)TEMP GROUP BY ID HAVING COUNT(ID) = 1

交集Intersect:
SELECT ID FROM (
SELECT DISTINCT A.AID AS ID FROM TABLE_A A
UNION ALL
SELECT DISTINCT B.BID AS ID FROM TABLE_B B
)TEMP GROUP BY ID HAVING COUNT(ID) = 2

不过,上述方法的功能也有限,
只能用来检查某个id是不是A、B表中都存在,
或者只存在于A、B表其中之一,
并不能对id在某表中多次出现做出检查。
而且,差集是有先后之分,这里没有。
2. http://hi.baidu.com/truetruelove/blog/item/f0fda8441bf22048510ffeba.html

1。求两表差集, ewb_t_books 是图书表,ewb_t_title是图书分类表,通过bt_titleid(not null)连接。
找出分类不存在的图书
a.子查询使用not in
#explain extended 
SELECT book_id,bt_titleid
FROM ewb_t_books b
WHERE bt_titleid NOT IN (SELECT bt_titleid FROM ewb_t_title)
#show warnings;

b.子查询 not exists
#explain extended 
SELECT book_id,bt_titleid
FROM ewb_t_books b
WHERE NOT EXISTS (SELECT * FROM ewb_t_title a WHERE b.bt_titleid= a.bt_titleid )
#show warnings;

c.左连接判断右表is null
#explain extended 
SELECT book_id,bt_titleid
FROM ewb_t_books LEFT JOIN ewb_t_title b USING (bt_titleid) 
WHERE ISNULL(b.bt_titleid)
#show warnings;

总结:简单测试了一下,not in最慢,其他两个平分秋色,有待考证。

select * from employee where salary<>3000;

  对这个查询,可以改写为不使用NOT:

select * from employee where salary<3000 or salary>3000;

  虽然这两种查询的结果一样,