In php, Moving a new row to another table and deleting old row


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting In php, Moving a new row to another table and deleting old row
# 1  
Old 06-12-2013
In php, Moving a new row to another table and deleting old row

Hi, I already succeed moving a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla).

But it can't delete the old row. Please help me with the script.

my php script:

Code:
INSERT INTO inbox_spam SELECT * FROM inbox 
WHERE TextDecoded NOT regexp ( select concat_ws ( '', '^(', group_concat(sms_keyword separator '|'), ').*' ) from sms_key)

Code:
select * from sms_key;
+-------------+
| sms_keyword |
+-------------+
| IRC         |
| PTM         |
| ADM         |
| BS          |
+-------------+

Code:
select * from inbox;
+------+----------------+
| x    | textdecoded    |
+------+----------------+
|    1 | IRC test1      |
|    2 | Hello, World!  |
|    3 | PTM test1      |
|    4 | Test ADM test1 |
+------+----------------+

Code:
select * from inbox_spam;
+------+----------------+
| x    | textdecoded    |
+------+----------------+
|    2 | Hello, World!  |
|    4 | Test ADM test1 |
+------+----------------+

Thank you Smilie

Last edited by joeyg; 06-12-2013 at 03:01 PM.. Reason: Clarified title
# 2  
Old 06-12-2013
That does not look like PHP. What database is this?
# 3  
Old 06-12-2013
Hi, im using mysql. the script are trigered with bash script:

Code:
mysql -uroot -p123456 smsd -e "INSERT INTO inbox_spam 
SELECT * FROM inbox WHERE TextDecoded 
NOT regexp ( select concat_ws ( '', '^(', group_concat(sms_keyword separator '|'), ').*' ) from sms_key)"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add Row from First Row (Split Row)

HI Guys, I have Below Input :- RepigA_hteis522 ReptCfiEtrBsCll_aofe MSL04_MSL2_A25_1A 0 9 MSL04_MSL2_A25_1B 0 9 MSL04_MSL2_A25_1C 0 9 RepigA ReptCfiEtrBsCll hteis522 aofe MSL04_MSL2_A25_1A 0 9 MSL04_MSL2_A25_1B 0 9 MSL04_MSL2_A25_1C 0 9 Split Data in two first row... (2 Replies)
Discussion started by: pareshkp
2 Replies

2. Shell Programming and Scripting

awk to convert table-by-row to matrix table

Hello, I need some help to reformat this table-by-row to matrix? infile: site1 A:o,p,q,r,s,t site1 C:y,u site1 T:v,w site1 -:x,z site2 A:p,r,t,v,w,z site2 C:u,y site2 G:q,s site2 -:o,x site3 A:o,q,s,t,u,z site3 C:y site3 T:v,w,x site3 -:p,routfile: SITE o p q r s t v u w x y... (7 Replies)
Discussion started by: yifangt
7 Replies

3. Shell Programming and Scripting

Moving new row and deleting old row to another table

Hi, I want to move a new row to another table if the field from new row doesn't have the first word that I categorized (like: IRC blablabla, PTM blablabla, ADM blablabla, BS blablabla). I already use this script but doesn't work as I expected. CHECK_KEYWORD="$( mysql -uroot -p123456 smsd -N... (7 Replies)
Discussion started by: jazzyzha
7 Replies

4. Shell Programming and Scripting

deleting dupes in a row

Hello, I have a large database in which name homonyms are arranged in a row. Since the database is large and generated by hand, very often dupes creep in. I want to remove the dupes either using an awk or perl script. An input is given below The expected output is given below: As can be... (2 Replies)
Discussion started by: gimley
2 Replies

5. UNIX for Dummies Questions & Answers

Finding files with one row then moving them

Hi guys can you please help me with a script to find files with one row the move the file to another directory the files are in /optima/prd/optdir/ZTE_BSS/Combiner/ZTE_2G/out/BSC_PS_Basic_Meas and I want to move them to /optima/prd/optdir/ZTE_BSS/Loader/error/ZTE_2G/BSC_PS_Basic_Meas ... (5 Replies)
Discussion started by: Dj Moi
5 Replies

6. UNIX for Dummies Questions & Answers

Shell Script: Traverse Database Table Row by Row

Hello Everyone, My issue is that I want to traverse a database table row by row and do some action on the value retrieved in each row. I have gone through a lot of shell script questions/posts. I could find row by row traversal of a file but not a database table. Please help. Thanks &... (5 Replies)
Discussion started by: ahsan.asghar
5 Replies

7. Shell Programming and Scripting

Moving data from a specified column/row to another column/row

Hello, I have an input file like the following: 11_3_4 2_1_35 3_15__ _16989 Where '_' is a space. The data is in a table. Is there a way for the program to prompt the user for x1,y1 and x2,y2, where x1,y1 is the desired number (for example x=6 y=4 is a value of 4) and move to a desired spot... (2 Replies)
Discussion started by: jl487
2 Replies

8. UNIX for Dummies Questions & Answers

deleting a row if a certain column is below a certain number

How can you delete a row if a certain column is bigger than a certain number? I have the following input: 20080709 20081222 95750 1 0 0.02 94.88 20080709 20081222 95750 2 0 0.89 94.88 20080709 20081222 9575 1 0 0 94.88 20080709 20081222 9575 2 0 0 94.88 20080709 20081222 9587.5 1 0 0... (6 Replies)
Discussion started by: Pep Puigvert
6 Replies

9. UNIX for Dummies Questions & Answers

deleting a row if a certain column is below a certain number

How can you delete a row if a certain column is bigger than a certain number? I have the following input: 20080709 20081222 95750 1 0 0.02 94.88 20080709 20081222 95750 2 0 0.89 94.88 20080709 20081222 9575 1 0 0 94.88 20080709 20081222 9575 2 0 0 94.88 20080709 20081222 9587.5 1 0 0... (1 Reply)
Discussion started by: Pep Puigvert
1 Replies

10. Shell Programming and Scripting

Deleting all occurences of a duplicate row

Hi, I need to delete all occurences of the repeated lines from a file and retain only the lines that is not repeated elsewhere in the file. As seen below the first two lines are same except that for the string "From BaseLine" and "From SMS".I shouldn't consider the string "From SMS" and "From... (7 Replies)
Discussion started by: ragavhere
7 Replies
Login or Register to Ask a Question