Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.NET -> sql select query

Posted on 2014-02-12
4
Medium Priority
?
448 Views
Last Modified: 2014-02-28
Hello,

I would like to select * from mysql table where Hometeam ="" or Awayteam=""

Then thing is I pull a list of matches that will be played each day so for instance today matches are:

23:20 Fortaleza V Ferroviario Fortaleza
22:30 Sao Paulo RS V Brasil de Pelotas
22:30 Rio Branco SP V Guaratingueta
22:30 Velo Clube V Ferroviaria
22:30 Sao Caetano V Mirassol
22:30 Itapirense V Osasco
22:00 Barbarense V Capivariano
21:45 Deportivo Anzoategui V Penarol
21:30 Ponte Preta V Ituano
21:30 Chapecoense V Hermann Aichinger
21:30 America MG V URT
21:00 Sociedad V Barcelona
21:00 Gremio Barueri V Santo Andre
20:00 Fulham V Liverpool
19:55 Nice V Monaco
19:45 Arsenal V Man Utd
19:45 Newcastle V Tottenham
19:45 Man City V Sunderland
19:45 Everton V C Palace
19:45 Stoke V Swansea
19:45 Sheff Utd V Brentford
19:45 Napoli V Roma
19:30 Hamburg V B Munich
19:00 Ourense V CD Alcala
18:45 Groningen V Twente
18:00 Hoffenheim V Wolfsburg
18:00 Leverkusen V Kaiserslautern
18:00 GAIS V Falkenbergs
18:00 Eskisehirspor V Sivasspor
18:00 Galatasaray V Antalyaspor
18:00 Bursaspor V Akhisar Belediye
18:00 Atromitos V Olympiakos
18:00 Real Union V SD Balmaseda FC
18:00 SC Wiedenbruck V FC Koln II
18:00 Netherlands (W) V Belgium (W)
18:00 Monte Azul V Guarani SP
18:00 Sao Jose EC SP V Catanduvense
17:45 Auxerre V Rennes
17:30 Supersport Utd V MP Black Aces
17:30 Platinum Stars V Bloemfontein Celtic
17:00 Hapoel Haifa V Hapoel Kiryat Shmona
16:00 Zaragoza B V CD Guadalajara
15:00 Dinamo Moscow V Dnipro
15:00 Olympiakos Volou V Panathinaikos
14:30 Arka Gdynia V Stomil Olsztyn
13:30 Ural V Rostov


how could i loop through to get each team name and place them in the Hometeam= "" and awayteam ="" ????
0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39853653
Not sure I understand the problem. You have a list of match strings as shown in question and you want to split these into home town and away town? How would you identify that? Is the first team always the home team?
0
 

Author Comment

by:runnerjp2005
ID: 39853691
correct first team is always home....

In essence i would like to do something like this

select * from mysql table where Hometeam ="Stoke" or Awayteam="Stoke" or Hometeam ="Swansea" or Awayteam="Swansea" or Hometeam ="Sheff%Utd" or Awayteam="Sheff%Utd" or Hometeam ="Brentford" or Awayteam="Brentford" .......

Notice the % inbetween Sheff%Utd as where a space is i would like to search if its like  Sheff%Utd incase its listed as Sheffield Utd
0
 
LVL 9

Accepted Solution

by:
dustock earned 2000 total points
ID: 39854074
I wasn't sure where the matches were so I wrote the VB assuming the matches were in a list box.  I'm sure the split can be done with regex but this works too.

        Dim strWords As String()
        Dim strQuery As String

        For Each strMatch As String In ListBox2.Items
            strMatch = strMatch.Replace(" V ", " - ") 'Replace V with - to avoid issues with teams with a V in the name
            strWords = strMatch.Substring(5).Split(New Char() {"-"})


            strQuery = "Select * from mysql table where Hometeam = '" + strWords(0).Trim + "' Or Awayteam = '" + strWords(1).Trim + "'"
        Next

Open in new window

0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39854247
"Stoke" hmm. That brings back some memories :-)
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question