?
Solved

VB.NET -> sql select query

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

762 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