I have the query to select some columns from two tables, which must contain some cells which are actually empty but have to name it in query such as
select name, REPLACE(format, ' – ', '/') as format, CAST(price AS UNSIGNED INTEGER) as price, CONCAT('http://example.com/',url_key) as url, level_id_value, delivery, sku from t1 where delivery <> 'slut' INTO OUTFILE 'test.txt' FIELDS TERMINATED BY '\t';
which perfectly works producing 2.5 MB size text file in lib folder but the other code as follows for another query where i have to add one column from another table along with some empty columns with some title, seems to work but produces a file size of around 11GB,
sELECT t1.sku, t.name, ' ' as Size, format, ' ' as subcategory, CAST(t1.price AS UNSIGNED INTEGER) as price, ' ' as dummy, CONCAT('http://example.com/',t1.url_key) as url, CONCAT('Från ',t1.level_id_value) as shipping_fee, t2.is_in_stock as stock, ' ' as text1, ' ' as Description from t2,t1 where t1.delivery <> 'slut' INTO OUTFILE 'test.txt' FIELDS TERMINATED BY '\t';
any help to debug this issue would be appreciable, don know much about mysql, so detailed explanation are highly welcome. Is there a way where i can make the code analogous to the first working code from two tables? I just need one column from t2 table, that is is_in_stock.
So the first one is a simple query SELECT INTO with a WHERE clause, this is going to return a small number of results.
The second one is showing an implicit inner join, but you arent returning the values based on a unique row, you just pull in everything from both tables, regardless of whether they are matching in both tables
This one is how I would do it, but you still need to isolate each record, so what makes each row unique, and do the inner join ON those fields between t1 and t2 like inner join t2 ON t1.name = t2.name and t1.id = t2.id but it should look something like this
Hope it helps!