?
Solved

VB.NET -> sql select query

Posted on 2014-02-12
4
Medium Priority
?
451 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
  • 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

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Integration Management Part 2
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

862 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