i want to search the database mysql and i want to find similar links

lets say i have this links in the database

and i want to search for all the links that look like
want the command to output

and not
i know this command the like command but its not working as u want
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sander StadSysteemontwikkelaar, Database AdministratorCommented:
In deed you need the "LIKE" command to get those values. Can you show me the query you originally created that doesn't work?
mgtm3Author Commented:
     $query = "    SELECT * FROM ddd WHERE d_link LIKE '%$link%'; ";
mgtm3Author Commented:
soo anyone?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

Sander StadSysteemontwikkelaar, Database AdministratorCommented:
Because you want to search for links in a database that start with a certain string you'd like to split the string before searching for it.
The code below creates an array with all the pieces of the url split by the "/". Than a query is set up to get all the needed results. After that the results are displayed.

$link = "www.dsdxa.com";
$pieces = explode("/", $link);
$query = "SELECT * FROM {tablename} WHERE {column} LIKE \"%$pieces[0]%\";";
$results = mysql_query($query);
while($row = mysql_fetch_array($results)){
  echo "$row['{column}']";

Open in new window

mgtm3Author Commented:
no thats to long i want something fast like the match command
Sander StadSysteemontwikkelaar, Database AdministratorCommented:
How do you man it is too long. I only gave an example how you can test it. You don't have to use the whole code. You only have to use the the first 5 rows. The rest is just meant as an example.
By the way you'd have to use the rest in some way because you'd have to execute the query against the database.
mgtm3Author Commented:
i mean it takes alout of time i have a huge database
now its 6 million rows
have you thought about using a FULLTEXT index?


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sander StadSysteemontwikkelaar, Database AdministratorCommented:

I think you misunderstood what I meant with the code to split up the searchstring. The reason why I split up the searchstring is that you want to be able to find a part of the string in your database.
You'll probably only want to search for the first part of a url and that is what you'll get with the code I posted. You can even create an if-statement to search the rest of the database with rest of the pieces of url that are in the searchstring if there is no result in the first part.
I didn't mean that you'd have to split up every url in the 6 million row database. Only the searchstring that somebody or something sends to the server to search for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.