Hot answers tagged

2

Theoretically you could end up with duplicate usernames. In a scenario of high incoming requests, a race condition could occur. If you want to avoid this, just put an UNIQUE index on your column. You could create a UNIQUE index on username by using this query: CREATE UNIQUE INDEX IDX_USERNAME ON `user_tbl` (`username`); Prior to creating this unique ...


1

Looks like a list of match results and you want to get won/lost points: SELECT team, SUM(pointa), SUM(pointb) FROM ( -- use all rows twice with switched points SELECT teama AS team, pointa, pointb FROM tab UNION ALL SELECT teamb, pointb, pointa FROM tab ) AS dt GROUP BY team


1

You could write a simple query using OR in WHERE clause and passing your search string. SELECT school_name FROM schools WHERE Subject1 = 'Physics' OR Subject2 = 'Physics' OR Subject3 = 'Physics' OR Subject4 = 'Physics' You can parameterize the search string and pass on to this query.



Only top voted, non community-wiki answers of a minimum length are eligible