我有2个MySQL表:subscriptions
和groups.
表sid
中的列subscriptions
包含负值,但表id
中的列groups
包含相同的值,但为正值。
我需要一些方法在加入表格sid
之前将groups
值转换为正值,或者将表id
中的所有值都视为负值的查询
以下是我的查询。它没有返回任何结果,因为列sid
包含负值,但列id
包含正值
$tmp = mysqli_query($con1,"
SELECT s.uid
, s.sid
, g.title
FROM subscriptions s
LEFT
JOIN groups g
ON s.sid = g.id
WHERE s.uid = $id
LIMIT 0,20
") or die('Error8');
答案 0 :(得分:3)
public class AndroidRssReader extends ListActivity {
private RSSFeed myRssFeed = null;
ProgressDialog progressDialog;
private String kat;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainrss);
Bundle extras = getIntent().getExtras();
if(extras != null) {
if(extras.containsKey("cat_name")) {
String kat = extras.getString("cat_name");
MyTask task = new MyTask();
task.execute(kat);
Toast.makeText(AndroidRssReader.this, kat, Toast.LENGTH_LONG).show(); // here I'm getting kat value properly!!!
}
}
}
private class MyTask extends AsyncTask<String, Void, Void>{
@Override
protected Void doInBackground(String... params) {
String kat = params[0];
Log.d("AJDE!", kat); // here, I'm getting kat value properly in logcat, why kat doesnt go toURL rssUrl ???
try {
URL rssUrl = new URL("http://www.example.com/category/" + kat + "/feed/");
SAXParserFactory mySAXParserFactory = SAXParserFactory.newInstance();
SAXParser mySAXParser = mySAXParserFactory.newSAXParser();
XMLReader myXMLReader = mySAXParser.getXMLReader();
RSSHandler myRSSHandler = new RSSHandler();
myXMLReader.setContentHandler(myRSSHandler);
InputSource myInputSource = new InputSource(rssUrl.openStream());
myXMLReader.parse(myInputSource);
myRssFeed = myRSSHandler.getFeed();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (myRssFeed!=null)
{
TextView feedTitle = (TextView)findViewById(R.id.feedtitle);
TextView feedSadrzajPosta = (TextView)findViewById(R.id.feedsadrzaj_posta);
TextView feedPubdate = (TextView)findViewById(R.id.feedpubdate);
TextView feedLink = (TextView)findViewById(R.id.feedlink);
feedTitle.setText(myRssFeed.getTitle());
feedSadrzajPosta.setText(myRssFeed.getSadrzajPosta());
feedPubdate.setText(myRssFeed.getPubdate());
feedLink.setText(myRssFeed.getLink());
ArrayAdapter<RSSItem> adapter =
new ArrayAdapter<RSSItem>(getApplicationContext(),
R.layout.list_black_text,R.id.list_content,myRssFeed.getList());
setListAdapter(adapter);
// Toast.makeText(getApplicationContext(), "GGG: " + msg1, Toast.LENGTH_SHORT).show();
}else{
TextView textEmpty = (TextView)findViewById(android.R.id.empty);
textEmpty.setText("No Feed Found!");
}
super.onPostExecute(result);
}
/* @Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = ProgressDialog.show(AndroidRssReader.this, "Please WAIT", "Loading ...");
} */
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
Intent intent = new Intent(this,ShowDetails.class);
Bundle bundle = new Bundle();
bundle.putString("keyTitle", myRssFeed.getItem(position).getTitle());
bundle.putString("keySadrzajPosta", myRssFeed.getItem(position).getSadrzaj_posta());
bundle.putString("keyLink", myRssFeed.getItem(position).getLink());
bundle.putString("keyPubdate", myRssFeed.getItem(position).getPubdate());
intent.putExtras(bundle);
startActivity(intent);
}
}
功能可以满足您的需求:
返回X的绝对值。
请参阅https://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_abs