select * from mesajlar where not exists /*not exists or exists */ ( select * from uyeler where mesajlar.gonderen = uyeler.id )
Kategori arşivi: Mysql
ÖRNEK MYSQL PROCEDURE
CREATE DEFINER=`root`@`localhost` PROCEDURE `YeniProsedur`(`Param` int(11)) BEGIN DECLARE v1 INT DEFAULT 5; DECLARE Rand_IL int(10); DECLARE Rand_ILCE int(10); DECLARE RandDateStart int(10); DECLARE RandDateEnd int(10); DECLARE RasTarih datetime; DECLARE RasSayi int(10); WHILE v1 > 0 DO SET Rand_IL = (select id from iller order by rand() limit 1); SET Rand_ILCE = (select id from ilceler where sehirid=Rand_IL order by rand() limit 1); SET RandDateStart = UNIX_TIMESTAMP('2010-01-01'); SET RandDateEnd = UNIX_TIMESTAMP('2010-09-01'); SET RasTarih = (SELECT FROM_UNIXTIME(RAND() * (RandDateEnd - RandDateStart) + RandDateStart)); SET RasSayi = rand()*(999999-10)+10; /*INSERT INTO ##RasSayi##RasTarih##Rand_IL##Rand_ILCE##;*/ SET v1 = v1 - 1; END WHILE; END; /*5 adet rasgale veri atıyor dbye,*/
MYSQL RASGELE TARİH/SAAT
SELECT FROM_UNIXTIME(RAND() * 2147483647) AS `rand`;+---------------------+
| rand |
+---------------------+
| 1998-04-01 21:42:48 |
+---------------------+
MYSQL STORED PROCEDURE DEĞİŞKEN ÖRNEĞİM
DECLARE Rand_IL int(10); /*değişken veri açılıyor*/ DECLARE Rand_ILCE int(10);/*değişken veri açılıyor*/ SET Rand_IL = (select id from iller order by rand() limit 1); /*Değişken tanımlanıyor*/ SET Rand_ILCE = (select id from ilceler where sehirid=Rand_IL order by rand() limit 1);/*Değişken tanımlanıyor*/ select Rand_IL,Rand_ILCE;/*select ile örnek veri çıkartılıyor*/ yukarıda görülen örnek rasgale il ve o ile ait ilçe idsi şeçmemize yardımcı oluyor
MYSQL BEST CONFİG
[mysqld]
old_passwords=1
set-variable=local-infile=0
skip-external-locking
skip-host-cache
skip-locking
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
safe-show-database
back_log = 75
#log-slow-queries = /var/log/mysql/mysql-slow.log
long_query_time = 3
max_connections = 3000
key_buffer = 32M
myisam_sort_buffer_size = 64M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
read_rnd_buffer_size = 524288
table_cache = 1800
thread_cache_size = 384
interactive_timeout = 100
wait_timeout = 180
connect_timeout = 2
tmp_table_size = 64M
max_allowed_packet = 64M
max_connect_errors = 10
thread_concurrency = 4
query_cache_limit = 20M
query_cache_size = 16M
query_cache_type = 1
query_prealloc_size = 16384
query_alloc_block_size = 16384
low_priority_updates=1
[mysqld_safe]
open_files_limit = 8192
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M