mysql - PHP/SQL: Using only one query, SELECT rows from two tables if data is in both tables, or just SELECT from one table if not -


I have two rating / vote tables for user votes and figures and second for external votes. The table of external votes always contains data as it contains DEAFULT = 0, but the votes of users are only included in that data if any user has voted for that specific ID.

Then I do something like this:

  $ sql = 'Selection ratings_state.wots, ratings_state_at_tai, rating_stats.view, ratings_state.fav, rating_state.technology, ratings_interest WAT, rating_credited_rate_RATINGS, ratings_like WHERE rating_stats.imdbid =? And rating_state.imdbid = ratings_form. Imdbidircr 1 ';  

When I'm available, I want to select data from both tables or not just the second (external vote) table.

How can I do this without a new query?

  select ratings_state.wots, ratings_stats_atata_wua, ratings_stats.view, rating_stats rating, stats_stats.wish, Ratings_excess.votes, ratings_external_out_value Rating_Returns out of index_rights_stats_stats_state ImdbID = ratings_external.imdbID WHERE rating_change.imdbid =? LIMIT 1  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -