MYSQLI and REGEXP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, sorry for the 2nd query today.

https://dev.mysql.com/doc/refman/8.0/en/regexp.html

I'm looking at the REGEXP screens and am a bit puzzled.

Basically all the examples shown are very similar to preg_match in PHP.
long bit of text, find short bit of text - if its included etc..

However, I cannot see an example of how this is effective / used in a
SELECT of a MYSQLI database/table.  it's only rexgexp'ing against
straight strings..


ive got a current SQL - which uses JOINS.

$sql = "SELECT Users.Username, Entities.*, Teams.* FROM Teams
LEFT JOIN Users
ON Users.PlayerID = Teams.PlayerID
LEFT JOIN Entities
ON Entities.PlayerID = Teams.PlayerID
 WHERE Teams.TeamID='$teamnumber';";

This works pretty well. except i'm wanting to add a regexp into it.
Basically  a regexp where Teams.playerID does NOT begin with "*"
(shifted-8)

similar to:
if(! preg_match("/\*/",$team[playerID])
{ get all the records in the joined table  }

I'll also copy the SQl in another table where playerID DOES match * (shift-8)

In both situations the PlayerID starts with * (or doesn't start with *)

1) get the team ID (primary start number)
2) get all PlayerID's with NO stars at the start of their player-Id
3) Do the joining and get the resulting data

Do the same 3 steps except I'm selecting players WITH a * at the start
of their player Id's - i'll select from a different table name.

-- 

Gordon.



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux