Rabbo Posted November 4, 2019 Report Posted November 4, 2019 I have a query which pulls 207K records, i have to add 2 columns (month and year will be columns ) for the last 2 years a,b,c are columns from query1 , month and year will be from query 2 i need same rows from query1 and query 2 rows change with month and year ila undhali result set a|b|c |month|year 207 records ki a|b|c|nov|2019 same 207k records a|b|c|oct|2019 and so on upto last 2 years which will be a|b|c|nov|2017 so total records will be 207K * 24 =5,589 K records Quote
WigsandThighs Posted November 4, 2019 Report Posted November 4, 2019 2 3 DELETE FROM table WHERE condition; works only in production Quote
Rabbo Posted November 4, 2019 Author Report Posted November 4, 2019 2 minutes ago, WigsandThighs said: 2 3 DELETE FROM table WHERE condition; works only in production lol, production ki andhuke only read access istharu ..... Quote
Tech_Babu Posted November 4, 2019 Report Posted November 4, 2019 look up examples on cross join Quote
Rabbo Posted November 4, 2019 Author Report Posted November 4, 2019 11 minutes ago, Tech_Babu said: look up examples on cross join adhe try chestuna bro, 1 hr run ayyi time out avthundi Quote
naaistamrabhai Posted November 4, 2019 Report Posted November 4, 2019 question ardam kale...tables endi...data endi... Quote
Spartan Posted November 4, 2019 Report Posted November 4, 2019 1 minute ago, naaistamrabhai said: question ardam kale...tables endi...data endi... Table 1 Table 2 a|b|c| oct|2019 after query Table 1 a|b|c|oct|2019 a|b|c|sep|2019 a|b|c|aug|2019 ....... a|b|c|oct|2017 Quote
kevinUsa Posted November 4, 2019 Report Posted November 4, 2019 1 minute ago, Spartan said: Table 1 Table 2 a|b|c| oct|2019 after query Table 1 a|b|c|oct|2019 a|b|c|sep|2019 a|b|c|aug|2019 ....... a|b|c|oct|2017 join cheste set kada on the primary key wht do u need simple no Quote
Sarvapindi Posted November 4, 2019 Report Posted November 4, 2019 1 hour ago, Rabbo said: I have a query which pulls 207K records, i have to add 2 columns (month and year will be columns ) for the last 2 years a,b,c are columns from query1 , month and year will be from query 2 i need same rows from query1 and query 2 rows change with month and year ila undhali result set a|b|c |month|year 207 records ki a|b|c|nov|2019 same 207k records a|b|c|oct|2019 and so on upto last 2 years which will be a|b|c|nov|2017 so total records will be 207K * 24 =5,589 K records U should not do that...asal req endi sakkaga seppu jara Quote
Spartan Posted November 4, 2019 Report Posted November 4, 2019 Just now, kevinUsa said: join cheste set kada on the primary key wht do u need simple no nen only req cheppa..i know no details. Quote
Amrita Posted November 4, 2019 Report Posted November 4, 2019 1 hour ago, Rabbo said: I have a query which pulls 207K records, i have to add 2 columns (month and year will be columns ) for the last 2 years a,b,c are columns from query1 , month and year will be from query 2 i need same rows from query1 and query 2 rows change with month and year ila undhali result set a|b|c |month|year 207 records ki a|b|c|nov|2019 same 207k records a|b|c|oct|2019 and so on upto last 2 years which will be a|b|c|nov|2017 so total records will be 207K * 24 =5,589 K records You will add columns ( year and month) based on identifier on Table B. Is that identifier in table A? If so just join on that column. Quote
Rabbo Posted November 4, 2019 Author Report Posted November 4, 2019 1 hour ago, Spartan said: Table 1 Table 2 a|b|c| oct|2019 after query Table 1 a|b|c|oct|2019 a|b|c|sep|2019 a|b|c|aug|2019 ....... a|b|c|oct|2017 Question baga ardam ayyindhi neeku Answer cheppu bro .. cross join use cheste time out avthundi table 2 is just generating month and year for last 2 years Quote
Rabbo Posted November 4, 2019 Author Report Posted November 4, 2019 1 hour ago, Amrita said: You will add columns ( year and month) based on identifier on Table B. Is that identifier in table A? If so just join on that column. Identifier ledu on table b Quote
Spartan Posted November 4, 2019 Report Posted November 4, 2019 18 minutes ago, Rabbo said: Question baga ardam ayyindhi neeku Answer cheppu bro .. cross join use cheste time out avthundi table 2 is just generating month and year for last 2 years since there is no common identifier...u can try to do UNION SELECT column1, column2, etc FROM table1 UNION SELECT column1, column2, etc FROM table2 Quote
Spartan Posted November 4, 2019 Report Posted November 4, 2019 2 hours ago, Rabbo said: I have a query which pulls 207K records, i have to add 2 columns (month and year will be columns ) for the last 2 years a,b,c are columns from query1 , month and year will be from query 2 i need same rows from query1 and query 2 rows change with month and year ila undhali result set a|b|c |month|year 207 records ki a|b|c|nov|2019 same 207k records a|b|c|oct|2019 and so on upto last 2 years which will be a|b|c|nov|2017 so total records will be 207K * 24 =5,589 K records https://stackoverflow.com/questions/1797785/sql-join-two-tables-without-keys-relations Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.