This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM opp WHERE phone = '1234567' or cellPhone = '7654321'; | |
/* 改寫為 */ | |
SELECT * FROM opp WHERE phone = '1234567' | |
UNION | |
SELECT * FROM opp WHERE cellPhone = '7654321'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM opp WHERE phone = '1234567'or phone = '7654321'; | |
/* 改寫為 */ | |
SELECT * FROM opp WHERE phone IN('1234567', '7654321'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 欄位定義:`remark` varchar(50) NOT NULL */ | |
/* 執行時間:0.14 秒 */ | |
SELECT `id`, `gift_code` FROM gift WHERE `deal_id` = 640 AND remark = 115127; | |
/* 執行時間:0.005 秒 */ | |
SELECT `id`, `gift_code` FROM gift WHERE `deal_id` = 640 AND remark = '15127'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 執行時間:2.19 秒 */ | |
SELECT phone, COUNT(*) from post GROUP BY phone LIMIT 1; | |
/* 執行時間:2.02秒 */ | |
SELECT phone, COUNT(*) from post GROUP BY phone ORDER BY NULL LIMIT 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM table WHERE id >= 23423 LIMIT 11; | |
/* 10 + 1 每頁十筆資料 */ | |
SELECT * FROM table WHERE id >= 23433 LIMIT 11; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE post SET tag = 1 WHERE id IN (1,2,3); | |
sleep 0.01; | |
UPDATE post SET tag = 1 WHERE id IN (4,5,6); | |
sleep 0.01; | |
...... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * FROM table1 WHERE id IN (SELECT id FROM table2); | |
/* 可能引起同步的延遲,還可能導致同步出錯,特別是有設定 AUTO_INCREMENT 時 */ | |
INSERT INTO table1 (SELECT * FROM table2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package servletutils; | |
import com.google.common.base.Preconditions; | |
import javax.servlet.*; | |
import javax.servlet.http.*; | |
public class UnhandledExceptionFilter implements Filter { | |
public interface ErrorHandler { | |
void handle(HttpServletRequest request, HttpServletResponse response, Throwable throwable); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import java.util.Arrays; | |
import javax.servlet.ServletContext; | |
import javax.servlet.ServletException; | |
import org.apache.catalina.LifecycleListener; | |
import org.apache.commons.logging.Log; | |
import org.apache.commons.logging.LogFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CassandraEnvironmentRepository implements EnvironmentRepository { | |
private static final Logger logger = Logger.getLogger(CassandraEnvironmentRepository.class); | |
@Autowired | |
private PropertiesRepository propertiesRepository; | |
@Override | |
public Environment findOne(final String application, final String profile, final String label) { | |
Environment result = new Environment(profile, label); |
OlderNewer