Re: Searching For Modules In a DB

2010-08-12 Thread walter harms


Carlos Mennens schrieb:
 I have a database called 'gaming' and with in that database there are
 several tables and data. I was asked to find a module called 'ako
 ldap' and disable it (setting it from 1 to 0). My question is how in
 MySQL do I search for a string if I don't even know what table to
 search in? I know how to search using the 'select' statement as long
 as I know where the table data is. In this case I only know which
 database but nothing more except what I am looking for.
 
 Can anyone please point me in the right direction?
 


hi Carlos,

put your tables in one file each (dont remember the option)
then you can do

grep -l string path_where_datafiles/*

every file where string is in will be shown.

re,
 wh

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



opened_table status

2010-08-12 Thread jitendra ranjan
Hi,
 
I have opened_table status is too high but i don't want increase the value of 
table_cache and also dont want to flush table because it will reset the query 
cache. 
 
Now my question is how can i decrease the opened_table status ?
 
Thanks in advance
 
Jeetendra Ranjan
MySQL DBA



Re: idle query

2010-08-12 Thread Mike Spreitzer
I also find that if I have both tables in MyISAM and use STRAIGHT_JOIN to 
force the better query plan (enumerate the longer table, for each longer 
table row use the shorter table's index to pick out the one right matching 
row from the shorter table) then the server has low I/O utilization but 
the CPU utilization is about as high as can be expected for a single query 
running on a 16-CPU machine.  Why should this thing be CPU-bound?  Here is 
the query:

create table fp2 (p VARCHAR(200) NOT NULL,
   rcd DATETIME NOT NULL, rcms SMALLINT NOT NULL, msgid BIGINT NOT 
NULL,
   q VARCHAR(200) NOT NULL, scd DATETIME NOT NULL, scms SMALLINT NOT 
NULL,
   lat DECIMAL(14,3),
   INDEX p(p), INDEX q(q) )
   AS SELECT fldrcv.p, fldrcv.cd as rcd, fldrcv.cms as rcms,
   fldrcv.msgid as msgid, fldrcv.q, fldsnd.cd as scd, fldsnd.cms as 
scms,
   TIMESTAMPDIFF(SECOND, fldsnd.cd, fldrcv.cd) + 
(fldrcv.cms-fldsnd.cms)/1000 as lat
   FROM fldrcv STRAIGHT_JOIN fldsnd
   ON fldrcv.q=fldsnd.p AND fldrcv.qboot=fldsnd.pboot
   AND fldrcv.msgid=fldsnd.msgid;

and here is some `iostat -x 5` output that shows a total of less than 50% 
I/O utilization and about 15/16 CPU utilization:

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
   4.270.001.820.000.03   93.89

Device: rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz 
avgqu-sz   await  svctm  %util
sda   0.00 1.20  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdb   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdc   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdd   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sde   0.00 0.00  0.00  1.20 0.00 4.60 3.83 
0.000.00   0.00   0.00
sdf   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdg   0.00 0.00  4.40  3.20  2252.80  1434.00   485.11 
0.16   20.74  13.26  10.08
sdh   0.00 0.00  4.40  2.80  2252.80  1433.60   512.00 
0.13   18.44  12.89   9.28
sdi   0.00 0.00  4.20  2.80  2150.40  1433.60   512.00 
0.13   19.20  12.91   9.04
sdj   0.00 0.00  4.40  2.80  2252.80  1433.60   512.00 
0.16   22.44  15.56  11.20
dm-0  0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
dm-1  0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
   4.280.001.810.010.03   93.88

Device: rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz 
avgqu-sz   await  svctm  %util
sda   0.00 0.00  0.00  0.40 0.0012.8032.00 
0.004.00   4.00   0.16
sdb   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdc   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdd   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sde   0.00 0.00  0.00  0.60 0.00 3.80 6.33 
0.000.00   0.00   0.00
sdf   0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
sdg   0.00 0.00  4.40  3.00  2252.80  1433.80   498.19 
0.17   23.57  16.65  12.32
sdh   0.00 0.00  4.40  2.80  2252.80  1433.60   512.00 
0.16   21.67  14.78  10.64
sdi   0.00 0.00  4.40  2.80  2252.80  1433.60   512.00 
0.15   20.89  14.44  10.40
sdj   0.00 0.00  4.20  2.80  2150.40  1433.60   512.00 
0.15   21.71  14.74  10.32
dm-0  0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00
dm-1  0.00 0.00  0.00  0.00 0.00 0.00 0.00 
0.000.00   0.00   0.00


Thanks,
Mike Spreitzer




From:   Mike Spreitzer/Watson/i...@ibmus
To: Dan Nelson dnel...@allantgroup.com
Cc: MySql mysql@lists.mysql.com
Date:   08/11/2010 01:30 PM
Subject:Re: idle query



I finally started trying to optimize along the memory-based lines you 
suggested.  I am surprised to find that the query plan is to enumerate the 

memory-based table and then pick out the hundreds of related rows from the 

much larger MyISAM table.  What's going on here?

`show create table` says this about the relevant tables:

CREATE TABLE `fldsndm` (
  `p` varchar(200) NOT NULL,
  `cd` datetime NOT NULL,
  `cms` smallint(6) NOT NULL,
  `pip` char(15) NOT NULL,
  `pport` smallint(6) NOT NULL,
  `pboot` bigint(20) NOT NULL,
  `msgid` bigint(20) NOT NULL,
  `startgtime` bigint(20) NOT NULL,
  `datalen` int(11) NOT NULL,
  `toself` tinyint(1) DEFAULT NULL,
  `sepoch` bigint(20) NOT NULL DEFAULT '0',
  `c` decimal(11,3) NOT NULL DEFAULT '0.000',
  

RE: opened_table status

2010-08-12 Thread Gavin Towey
You don't need to flush tables, just increase the table_cache.

-Original Message-
From: jitendra ranjan [mailto:jitendra_ran...@yahoo.com]
Sent: Thursday, August 12, 2010 10:55 AM
To: mysql@lists.mysql.com
Subject: opened_table status

Hi,

I have opened_table status is too high but i don't want increase the value of 
table_cache and also dont want to flush table because it will reset the query 
cache.

Now my question is how can i decrease the opened_table status ?

Thanks in advance

Jeetendra Ranjan
MySQL DBA


This message contains confidential information and is intended only for the 
individual named.  If you are not the named addressee, you are notified that 
reviewing, disseminating, disclosing, copying or distributing this e-mail is 
strictly prohibited.  Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your system. 
E-mail transmission cannot be guaranteed to be secure or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any loss or damage caused by viruses or errors or omissions in the contents 
of this message, which arise as a result of e-mail transmission. [FriendFinder 
Networks, Inc., 220 Humbolt court, Sunnyvale, CA 94089, USA, FriendFinder.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



RE: opened_table status

2010-08-12 Thread jitendra ranjan
As our file descriptor does not allow to increase the table_cache is there any 
other way to decrease the occurence of opened_table ?

--- On Fri, 13/8/10, Gavin Towey gto...@ffn.com wrote:


From: Gavin Towey gto...@ffn.com
Subject: RE: opened_table status
To: jitendra ranjan jitendra_ran...@yahoo.com, mysql@lists.mysql.com 
mysql@lists.mysql.com
Date: Friday, 13 August, 2010, 12:06 AM


You don't need to flush tables, just increase the table_cache.

-Original Message-
From: jitendra ranjan [mailto:jitendra_ran...@yahoo.com]
Sent: Thursday, August 12, 2010 10:55 AM
To: mysql@lists.mysql.com
Subject: opened_table status

Hi,

I have opened_table status is too high but i don't want increase the value of 
table_cache and also dont want to flush table because it will reset the query 
cache.

Now my question is how can i decrease the opened_table status ?

Thanks in advance

Jeetendra Ranjan
MySQL DBA


This message contains confidential information and is intended only for the 
individual named.  If you are not the named addressee, you are notified that 
reviewing, disseminating, disclosing, copying or distributing this e-mail is 
strictly prohibited.  Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your system. 
E-mail transmission cannot be guaranteed to be secure or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any loss or damage caused by viruses or errors or omissions in the contents 
of this message, which arise as a result of e-mail transmission. [FriendFinder 
Networks, Inc., 220 Humbolt court, Sunnyvale, CA 94089, USA, FriendFinder.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=jitendra_ran...@yahoo.com





RHEL Auto Start / stop mysql???

2010-08-12 Thread Nunzio Daveri
Hi all, I just installed the no-install version of mysql 5.1.44 on our RHEL 5 
box AFTER I yum removed the older 4.X version.  The question is how do I tell 
RHEL to auto start and stop mysql when I have to reboot the server?  I know 
that 
if you use an rpm or a yum it kinda / sorta created a mysqld startup script in 
/etc/init.d but what all do I have to have and how do I set it up please since 
all I did was untar the file and then type in mysql_5/bin/mysqld_safe ?

I tried using the service command, but no luck there either.

Any help is much appreciated...

Nunzio


  

Re: RHEL Auto Start / stop mysql???

2010-08-12 Thread Guifre Bosch Fabregas
hi Nunzio!

Sorry but my english is very poor... (reading and writing! Thanks
http://translate.google.com/ ! )

At first can you install yet mysql?
If you have installet yet mysql you can go to /etc/init.d and look if the
startup script is in this directory.

I understand your question right?








2010/8/12 Nunzio Daveri nunziodav...@yahoo.com

 Hi all, I just installed the no-install version of mysql 5.1.44 on our RHEL
 5
 box AFTER I yum removed the older 4.X version.  The question is how do I
 tell
 RHEL to auto start and stop mysql when I have to reboot the server?  I know
 that
 if you use an rpm or a yum it kinda / sorta created a mysqld startup script
 in
 /etc/init.d but what all do I have to have and how do I set it up please
 since
 all I did was untar the file and then type in mysql_5/bin/mysqld_safe ?

 I tried using the service command, but no luck there either.

 Any help is much appreciated...

 Nunzio







-- 
Guifre Bosch Fabregas
Tlf.: 687911075


RESET MASTER doesn't work

2010-08-12 Thread Joe Hammerman
Hello MySQL-users list,

We are having an issue with replication and binlog files and I was hoping that 
this list could shed a little light on the issue for us. We have a pair of 
5.1.41-community MySQL servers. We attempted to restore from the slave server, 
and in the process I zeroed out the mysql-bin.index file with the echo command 
(I know this makes me a terrible person; in my own defense, this was effective 
technique for restoration on on 5.0 MySQL machines).

Now, when we run:

mysql show master status;

We see

+--+---+--+--+
| Fil| Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+--+---+--+--+
| mysql-bin.000121 | 429017611 |   ||
+--+---+--+--+

But if we run

mysql SHOW BINARY LOGS;

We see

Empty set (0.00 sec)

And the RESET MASTER command has no effect.

We saw on http://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html

Prior to MySQL 5.0.60, PURGE BINARY LOGS TO and PURGE BINARY LOGS BEFORE did 
not behave in the same way (and neither one behaved correctly) when binary log 
files listed in the .index file had been removed from the system by some other 
means (such as using rm on Linux). Beginning with MySQL 5.0.60, both variants 
of the statement fail with an error in such cases. (Bug#18199 
http://bugs.mysql.com/bug.php?id=18199 , Bug#18453 
http://bugs.mysql.com/bug.php?id=18453 ) To handle such errors, edit the 
.index file (which is a simple text file) manually to ensure that it lists only 
the binary log files that are actually present, then run again the PURGE BINARY 
LOGS purge-binary-logs.html  statement that failed.

However running PURGE BINARY LOGS against a file listed in the mysql-bin.index 
file (once this file has been updated to reflefc all of the logs contained 
within it's directory) still results in

ERROR 1373: Target log not found in binlog index

Can anyone shed some light on this issue for us?

Thanks!


Re: RHEL Auto Start / stop mysql???

2010-08-12 Thread Nunzio Daveri
Hi Guifre, thanks for answering.  I already have mysql installed and works just 
fine, but I did untar and then go to folder and run.  I used what is called 
mysql no-install so no yum, rpm etc..  No files in /etc/init.d and no startup 
or 
services script since this is using the no-install version.

Thanks...

Nunzio





From: Guifre Bosch Fabregas guifre.bo...@gmail.com
To: Nunzio Daveri nunziodav...@yahoo.com
Cc: mysql@lists.mysql.com
Sent: Thu, August 12, 2010 3:40:32 PM
Subject: Re: RHEL Auto Start / stop mysql???

hi Nunzio!

Sorry but my english is very poor... (reading and writing! Thanks 
http://translate.google.com/ ! )

At first can you install yet mysql?
If you have installet yet mysql you can go to /etc/init.d and look if the 
startup script is in this directory.

I understand your question right?









2010/8/12 Nunzio Daveri nunziodav...@yahoo.com

Hi all, I just installed the no-install version of mysql 5.1.44 on our RHEL 5
box AFTER I yum removed the older 4.X version.  The question is how do I tell
RHEL to auto start and stop mysql when I have to reboot the server?  I know 
that
if you use an rpm or a yum it kinda / sorta created a mysqld startup script in
/etc/init.d but what all do I have to have and how do I set it up please since
all I did was untar the file and then type in mysql_5/bin/mysqld_safe ?

I tried using the service command, but no luck there either.

Any help is much appreciated...

Nunzio


 


-- 
Guifre Bosch Fabregas
Tlf.: 687911075



  

mysql is crashing

2010-08-12 Thread Yectli Huerta
Hello,

I compiled a version of mysql 5.1.49 and it crashed a couple of times already.
I recompiled it with debug enabled and this is the error I got. Do any of
you guys/gals have any suggestions?

thanks,


this is from the trace file:

do_select: info: select cond 0xb7e088
do_select: info: select cond 0xb7e088
do_select: info: select cond 0xb7e088
do_select: info: select cond 0xb7e088
do_select: info: select cond 0xb7e088
intern_plugin_unlock: info: unlocking plugin, name= MyISAM, ref_count= 72
~THD(): info: freeing security context


below are the messages from the error log file

do_select: info: select cond 0xb7e088
do_select: info: select cond 0x2aabee71ed48
do_select: info: select cond 0xb7e088
do_select: info: select cond 0x2aabee71ed48
do_select: info: select cond 0xb7e088
*** glibc detected *** /opt/mysql/libexec/mysqld: corrupted double-linked list: 
0x2aabf301a720 ***
=== Backtrace: =
/lib64/libc.so.6[0x2b4fc154e6de]
/lib64/libc.so.6[0x2b4fc154f91d]
/lib64/libc.so.6(__libc_free+0x6c)[0x2b4fc154fd5c]
/opt/mysql/libexec/mysqld(my_no_flags_free+0x7b)[0x78356b]
/opt/mysql/libexec/mysqld(_ZN3THDD0Ev+0x3c1)[0x575dc7]
/opt/mysql/libexec/mysqld(_Z10unlink_thdP3THD+0xc7)[0x587dc9]
/opt/mysql/libexec/mysqld(_Z29one_thread_per_connection_endP3THDb+0x3f)[0x587e27]
/opt/mysql/libexec/mysqld(handle_one_connection+0xc31)[0x58d20f]
/lib64/libpthread.so.0[0x2b4fc0f6f193]
/lib64/libc.so.6(__clone+0x6d)[0x2b4fc15a3dfd]
=== Memory map: 
0040-00944000 r-xp  fd:00 8440267 /opt/mysql-5.1.49/libexec/mysqld
00a44000-00a96000 rw-p 00544000 fd:00 8440267 /opt/mysql-5.1.49/libexec/mysqld
00a96000-00c6c000 rw-p 00a96000 00:00 0 [heap]
4000-40001000 ---p 4000 00:00 0
40001000-40801000 rw-p 40001000 00:00 0
40801000-40802000 ---p 40801000 00:00 0
40802000-40842000 rw-p 40802000 00:00 0
40842000-40843000 ---p 40842000 00:00 0
40843000-40883000 rw-p 40843000 00:00 0
40883000-40884000 ---p 40883000 00:00 0
40884000-408c4000 rw-p 40884000 00:00 0
408c4000-408c5000 ---p 408c4000 00:00 0
408c5000-40905000 rw-p 408c5000 00:00 0
40905000-40906000 ---p 40905000 00:00 0
40906000-40946000 rw-p 40906000 00:00 0
40946000-40947000 ---p 40946000 00:00 0
40947000-40987000 rw-p 40947000 00:00 0
40987000-40988000 ---p 40987000 00:00 0
40988000-409c8000 rw-p 40988000 00:00 0
409c8000-409c9000 ---p 409c8000 00:00 0
409c9000-40a09000 rw-p 409c9000 00:00 0
40a09000-40a0a000 ---p 40a09000 00:00 0
40a0a000-40a4a000 rw-p 40a0a000 00:00 0
2aaad000-2be4c000 r--s  fd:04 62914806 /var/run/nscd/passwd
2be4c000-2c334000 r--s  fd:04 62914812 /var/run/nscd/group
2c334000-2aabee331000 rw-p 2c334000 00:00 0
2aabee70-2aabee7cb000 rw-p 2aabee70 00:00 0
2aabee7cb000-2aabee80 ---p 2aabee7cb000 00:00 0
2aabee80-2aabf0b36000 rw-p 2aabee80 00:00 0
2aabf1803000-2aabf2804000 rw-p 2aabf1803000 00:00 0
2aabf300-2aabf30e6000 rw-p 2aabf300 00:00 0
2aabf30e6000-2aabf310 ---p 2aabf30e6000 00:00 0
2aabf310-2aabf4aa7000 rw-p 2aabf310 00:00 0
2b4fc0e4d000-2b4fc0e68000 r-xp  fd:01 16818349 /lib64/ld-2.4.so
2b4fc0e68000-2b4fc0e6a000 rw-p 2b4fc0e68000 00:00 0
2b4fc0f67000-2b4fc0f69000 rw-p 0001a000 fd:01 16818349 /lib64/ld-2.4.so
2b4fc0f69000-2b4fc0f7d000 r-xp  fd:01 16818344 /lib64/libpthread-2.4.so
2b4fc0f7d000-2b4fc107c000 ---p 00014000 fd:01 16818344 /lib64/libpthread-2.4.so
2b4fc107c000-2b4fc107e000 rw-p 00013000 fd:01 16818344 /lib64/libpthread-2.4.so
2b4fc107e000-2b4fc1082000 rw-p 2b4fc107e000 00:00 0
2b4fc1082000-2b4fc1165000 r-xp  fd:03 37804570 
/usr/lib64/libstdc++.so.6.0.8
2b4fc1165000-2b4fc1265000 ---p 000e3000 fd:03 37804570 
/usr/lib64/libstdc++.so.6.0.8
2b4fc1265000-2b4fc126b000 r--p 000e3000 fd:03 37804570 
/usr/lib64/libstdc++.so.6.0.8
2b4fc126b000-2b4fc126e000 rw-p 000e9000 fd:03 37804570 
/usr/lib64/libstdc++.so.6.0.8
2b4fc126e000-2b4fc128 rw-p 2b4fc126e000 00:00 0
2b4fc128-2b4fc128d000 r-xp  fd:01 16818324 /lib64/libgcc_s.so.1
2b4fc128d000-2b4fc138c000 ---p d000 fd:01 16818324 /lib64/libgcc_s.so.1
2b4fc138c000-2b4fc138d000 rw-p c000 fd:01 16818324 /lib64/libgcc_s.so.1
2b4fc138d000-2b4fc138e000 rw-p 2b4fc138d000 00:00 0
2b4fc138e000-2b4fc13e2000 r-xp  fd:01 16818414 /lib64/libm-2.4.so
2b4fc13e2000-2b4fc14e1000 ---p 00054000 fd:01 16818414 /lib64/libm-2.4.so
2b4fc14e1000-2b4fc14e3000 rw-p 00053000 fd:01 16818414 /lib64/libm-2.4.so
2b4fc14e3000-2b4fc1619000 r-xp  fd:01 16818318 /lib64/libc-2.4.so
2b4fc1619000-2b4fc1719000 ---p 00136000 fd:01 16818318 /lib64/libc-2.4.so
2b4fc1719000-2b4fc171c000 r--p 00136000 fd:01 16818318 /lib64/libc-2.4.so
2b4fc171c000-2b4fc171e000 rw-p 00139000 fd:01 16818318 /lib64/libc-2.4.so
2b4fc171e000-2b4fc1723000 rw-p 2b4fc171e000 00:00 0
2b4fc1723000-2b4fc1737000 r-xp  fd:01 16818407 /lib64/libz.so.1.2.3
2b4fc1737000-2b4fc1836000 ---p 00014000 fd:01 16818407 /lib64/libz.so.1.2.3
2b4fc1836000-2b4fc1837000 rw-p 00013000 fd:01 16818407 

project/extract similar items type, inside a table field as if a field itself

2010-08-12 Thread MadTh
Hi,

There is a mysql table ( wordpress) as following, called wp_usermeta, where
field meta_key  holds zip_code , first_name, last_name inside it ( should
have been separate fields to extract data easily)


mysql desc wp_usermeta;
++-+--+-+-++
| Field  | Type| Null | Key | Default | Extra  |
++-+--+-+-++
| umeta_id   | bigint(20) unsigned | NO   | PRI | NULL| auto_increment |
| user_id| bigint(20) unsigned | NO   | MUL | 0   ||
| meta_key   | varchar(255)| YES  | MUL | NULL||
| meta_value | longtext| YES  | | NULL||
++-+--+-+-++
4 rows in set (0.00 sec)



mysql SELECT * FROM `wp_usermeta` WHERE `meta_key` LIKE 'zip_code' ORDER BY
user_id limit 1,3;
+--+-+--++
| umeta_id | user_id | meta_key | meta_value |
+--+-+--++
|  278 |  15 | zip_code | 32501  |
|  297 |  16 | zip_code | 32501  |
|  316 |  17 | zip_code | 32504  |
+--+-+--++
3 rows in set (0.00 sec)

mysql SELECT * FROM `wp_usermeta` WHERE `meta_key` LIKE 'first_name' ORDER
BY user_id limit 1,3;
+--+-+++
| umeta_id | user_id | meta_key   | meta_value |
+--+-+++
|  280 |  16 | first_name | Jesxxdx|
|  299 |  17 | first_name | maerer |
|  318 |  18 | first_name | Liddd  |
+--+-+++
3 rows in set (0.00 sec)

mysql SELECT * FROM `wp_usermeta` WHERE `meta_key` LIKE 'last_name' ORDER
BY user_id limit 1,3;
+--+-+---++
| umeta_id | user_id | meta_key  | meta_value |
+--+-+---++
|  281 |  16 | last_name | Oweccc |
|  300 |  17 | last_name | magf   |
|  319 |  18 | last_name | Pedfs  |
+--+-+---++
3 rows in set (0.01 sec)

mysql







Is it possible to exctract each items, zip_code , first_name, last_name
inside the field  meta_key separately and list them as if each item is a
field through a single mysql query.  Else, it seems we will have to extract
each file and then import that to a new table with a each of the field
created inside that table.




Result something like:



first_name last_namezip_code

JesxxdxOweccc 32501
maerer magf  32501
Liddd  Pedfs 32504






Thakns


RE: project/extract similar items type, inside a table field as if a field itself

2010-08-12 Thread Travis Ard
Maybe something like this:

select 
user_id
,max(if(meta_key = 'zip_code', meta_value, null)) as zip_code
,max(if(meta_key = 'first_name', meta_value, null)) as first_name
,max(if(meta_key = 'last_name', meta_value, null)) as last_name
from wp_usermeta
group by user_id;

-Travis

-Original Message-
From: MadTh [mailto:madan.feedb...@gmail.com] 
Sent: Thursday, August 12, 2010 4:08 PM
To: mysql@lists.mysql.com
Subject: project/extract similar items type, inside a table field as if a
field itself

Hi,

There is a mysql table ( wordpress) as following, called wp_usermeta, where
field meta_key  holds zip_code , first_name, last_name inside it ( should
have been separate fields to extract data easily)


mysql desc wp_usermeta;
++-+--+-+-++
| Field  | Type| Null | Key | Default | Extra  |
++-+--+-+-++
| umeta_id   | bigint(20) unsigned | NO   | PRI | NULL| auto_increment |
| user_id| bigint(20) unsigned | NO   | MUL | 0   ||
| meta_key   | varchar(255)| YES  | MUL | NULL||
| meta_value | longtext| YES  | | NULL||
++-+--+-+-++
4 rows in set (0.00 sec)



mysql SELECT * FROM `wp_usermeta` WHERE `meta_key` LIKE 'zip_code' ORDER BY
user_id limit 1,3;
+--+-+--++
| umeta_id | user_id | meta_key | meta_value |
+--+-+--++
|  278 |  15 | zip_code | 32501  |
|  297 |  16 | zip_code | 32501  |
|  316 |  17 | zip_code | 32504  |
+--+-+--++
3 rows in set (0.00 sec)

mysql SELECT * FROM `wp_usermeta` WHERE `meta_key` LIKE 'first_name' ORDER
BY user_id limit 1,3;
+--+-+++
| umeta_id | user_id | meta_key   | meta_value |
+--+-+++
|  280 |  16 | first_name | Jesxxdx|
|  299 |  17 | first_name | maerer |
|  318 |  18 | first_name | Liddd  |
+--+-+++
3 rows in set (0.00 sec)

mysql SELECT * FROM `wp_usermeta` WHERE `meta_key` LIKE 'last_name' ORDER
BY user_id limit 1,3;
+--+-+---++
| umeta_id | user_id | meta_key  | meta_value |
+--+-+---++
|  281 |  16 | last_name | Oweccc |
|  300 |  17 | last_name | magf   |
|  319 |  18 | last_name | Pedfs  |
+--+-+---++
3 rows in set (0.01 sec)

mysql







Is it possible to exctract each items, zip_code , first_name, last_name
inside the field  meta_key separately and list them as if each item is a
field through a single mysql query.  Else, it seems we will have to extract
each file and then import that to a new table with a each of the field
created inside that table.




Result something like:



first_name last_namezip_code

JesxxdxOweccc 32501
maerer magf  32501
Liddd  Pedfs 32504






Thakns


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org